fix(hooks): add null guard for tool.execute.after output #1054
+28
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
outputparameter intool.execute.afterhooks/reviewcommand (and other Claude Code built-in commands) trigger hooks withundefinedoutputProblem
Claude Code's
/reviewcommand triggerstool.execute.afterhooks but passesoutputasundefinedinstead of the expected object withoutput,metadata, andtitleproperties. This causes crashes when hooks try to accessoutput.metadata.Solution
Added early return guards in three locations (defense-in-depth):
src/index.ts): Guards all downstream hookssrc/hooks/claude-code-hooks/index.ts): Additional safety layersrc/hooks/atlas/index.ts): Additional safety layerChanges
src/index.ts: Addif (!output) returnguard at start oftool.execute.afterhandlersrc/hooks/claude-code-hooks/index.ts: Addif (!output) returnguardsrc/hooks/atlas/index.ts: Addif (!output) returnguardsrc/hooks/atlas/index.test.ts: Add test for undefined output handlingTesting
Fixes #1035
Summary by cubic
Add null guards in tool.execute.after to handle undefined output from /review and other Claude Code commands, preventing crashes. Fixes #1035.
Written for commit e9412bd. Summary will update on new commits.