Skip to content

Conversation

@zimeg
Copy link
Member

@zimeg zimeg commented Jul 25, 2025

Changelog

We added a new runtime_not_found error code that appears when a hook script cannot be found because the runtime for a project wasn't found during execution.

Summary

This PR errors with a runtime_not_found error if the hook runtime doesn't exist when a sdk_hook_not_found error is returned.

With this change, we make use of hook resolution and assume that if the runtime isn't set, that wasn't returned in the response from get-hooks.

In sample applications and with init we suggest gathering hook values from the get-hooks script and don't override the runtime value. IMO this is good for the happy path cases! Additional hook customizations might run into unexpected errors with a customized runtime but debugging information remains available in verbose outputs 👾

Preview

🔍 Errors when a hook is not found and the runtime doesn't exist follow:

runtime

🔍 Errors when a hook is found but errors, without a runtime, continue to error:

hook

Reviewers

Uninstall various runtimes and attempt to interact with a matching app:

$ slack create asdf
$ cd asdf
$ slack manifest

Notes

  • A follow up to not error if the get-hooks script errors is needed so that other hooks can still be parsed, if defined.

Requirements

@zimeg zimeg added this to the Next Release milestone Jul 25, 2025
@zimeg zimeg self-assigned this Jul 25, 2025
@zimeg zimeg requested a review from a team as a code owner July 25, 2025 23:36
@zimeg zimeg added enhancement M-T: A feature request for new functionality changelog Use on updates to be included in the release notes semver:patch Use on pull requests to describe the release version increment labels Jul 25, 2025
@codecov
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.08%. Comparing base (bed795a) to head (c466968).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/root.go 88.88% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #167   +/-   ##
=======================================
  Coverage   63.07%   63.08%           
=======================================
  Files         212      212           
  Lines       21667    21672    +5     
=======================================
+ Hits        13666    13671    +5     
+ Misses       6951     6950    -1     
- Partials     1050     1051    +1     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

📝 Leaving a few notes for the kind reviewers!

Comment on lines +383 to +386
if slackerror.Is(err, slackerror.ErrSDKHookNotFound) && clients.SDKConfig.Runtime == "" {
err = slackerror.New(slackerror.ErrRuntimeNotFound).
WithRootCause(slackerror.ToSlackError(err).WithRemediation(""))
}
Copy link
Member Author

Choose a reason for hiding this comment

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

🔏 note: The runtime is unknown to actual hook scripts, so the runtime_not_found error can't be determined during hook execution itself...

🤔 question: Does this error handling logic make sense to include at the root command cleanup, or should hook executions be checked for this?

Comment on lines +393 to +395
clients.EventTracker.SetErrorMessage(err.Error())
if slackErr, ok := err.(*slackerror.Error); ok {
clients.EventTracker.SetErrorCode(slackErr.Code)
Copy link
Member Author

Choose a reason for hiding this comment

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

🔍 note: Moved this since we now might update the err value!

@zimeg
Copy link
Member Author

zimeg commented Jul 25, 2025

🗣️ note: This is followup in preparation for changes from #165!

Copy link
Member

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

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

✅ Thanks for updating this! It's a very nice improvement to debug why a hook has failed.

🧪 Manual testing worked well - I tested using Deno. 🦕


func triggerRequestViaHook(ctx context.Context, clients *shared.ClientFactory, path string, isDev bool) (api.TriggerRequest, error) {
if !clients.SDKConfig.Hooks.GetTrigger.IsAvailable() {
return api.TriggerRequest{}, slackerror.New(slackerror.ErrSDKHookGetTriggerNotFound)
Copy link
Member

Choose a reason for hiding this comment

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

praise: I like that you've chosen to remove this very-specific hook error for the general ErrSDKHookNotFound and Remediation combination.

Copy link
Member Author

Choose a reason for hiding this comment

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

thought: Once errors across packages are wrapped I'm optimistic these same details will be clear in output messages 🙏

@zimeg
Copy link
Member Author

zimeg commented Aug 11, 2025

@mwbrooks And thanks for the kind review! 👁️‍🗨️ ✨

Let's merge this now but continue the efforts to improved hook debugging. I'm optimistic that #174 can be a next good step for troubleshooting steps.

@zimeg zimeg merged commit 783db56 into main Aug 11, 2025
6 checks passed
@zimeg zimeg deleted the zimeg-feat-runtime-not-found-error branch August 11, 2025 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog Use on updates to be included in the release notes enhancement M-T: A feature request for new functionality 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.

3 participants