Skip to content

fix(hooks): show the watch configuration hint when hooks omit the watch config - #838

Merged
mwbrooks merged 2 commits into
mainfrom
mwbrooks-fix-watch-opts-pointer
Nov 23, 2026
Merged

mwbrooks merged 2 commits into
mainfrom
mwbrooks-fix-watch-opts-pointer

Conversation

@mwbrooks

@mwbrooks mwbrooks commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Changelog

N/A - fixes a debug message only.

Summary

This pull request shows developers the "To watch file changes, provide watch configuration in .slack/hooks.json" debug hint again when their SDK hooks leave out the watch config. hooks.SDKCLIConfig.Config.Watch was a WatchOpts value, so Watch.IsAvailable() checked the address of a struct field and was always true. That meant the hint in WatchManifest and WatchApp could never print.

  • Makes Config.Watch a *WatchOpts, so a missing watch key unmarshals to nil. IsAvailable, GetManifestWatchConfig, and GetAppWatchConfig already handle a nil receiver.
  • Adds cases to Test_WatchOpts_IsAvailable that unmarshal hooks JSON with and without watch

Found while adding tests for WatchManifest in #831 (a PR). If #839 (a PR) merges first, this PR updates its test to set Watch as a pointer.

Testing

  1. Run go test ./internal/hooks/... -run Test_WatchOpts_IsAvailable -v
  2. Optional: in an app whose get-hooks output has no config.watch, run slack run --verbose and confirm the "provide watch configuration" debug line prints

Requirements

@mwbrooks mwbrooks added this to the Next Release milestone Nov 23, 2026
@mwbrooks mwbrooks added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch Use on pull requests to describe the release version increment labels Nov 23, 2026
@mwbrooks mwbrooks self-assigned this Nov 23, 2026
@mwbrooks
mwbrooks marked this pull request as ready for review November 23, 2026 22:13
@mwbrooks
mwbrooks requested a review from a team as a code owner November 23, 2026 22:13
@mwbrooks
mwbrooks requested review from WilliamBergamin and zimeg and removed request for a team November 23, 2026 22:13
@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.54%. Comparing base (27677da) to head (9c3dda5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #838   +/-   ##
=======================================
  Coverage   80.54%   80.54%           
=======================================
  Files         246      246           
  Lines       18899    18899           
=======================================
+ Hits        15222    15223    +1     
+ Misses       3677     3676    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@WilliamBergamin WilliamBergamin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 @mwbrooks thanks! Turning Watch into a pointer is the smallest fix here, since the nil checks on WatchOpts were already waiting for it.
Nothing blocking, ready to go 🚀

hooksJSON: `{"config":{}}`,
expectedIsAvailable: false,
},
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 praise: Unmarshalling real hooks JSON with and without watch tests the exact case that was broken, not just a hand-built nil.

@mwbrooks

Copy link
Copy Markdown
Member Author

Thanks @WilliamBergamin for the quick review! 🙇

@mwbrooks
mwbrooks merged commit d3904d1 into main Nov 23, 2026
14 checks passed
@mwbrooks
mwbrooks deleted the mwbrooks-fix-watch-opts-pointer branch November 23, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants