Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: ba5daaf The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
||||||||||||||||
|
|
||||||||||||||||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
tgmendes
left a comment
There was a problem hiding this comment.
Looking good overall, but we should separate the migrations to it's own PR for isolation.
Also it feels like there are really 2 different changes going on in this PR which I would've consider separating:
- Tool name renaming (not using gram URN)
- Actual hooks work
Either way as long as the migrations are in a separate PR I think this should be good to go soon
| validate_env_vars() { | ||
| local hook_event_name="$1" | ||
|
|
||
| echo "RUNNING HOOK $hook_event_name" |
There was a problem hiding this comment.
🔴 Debug echo to stdout corrupts JSON hook response
The validate_env_vars function prints echo "RUNNING HOOK $hook_event_name" to stdout (line 13). Since Claude Code hooks expect the command's stdout to be a valid JSON response, this debug line prepends non-JSON text before the actual JSON output from output_success_json or output_block_json, producing malformed output like:
RUNNING HOOK PreToolUse
{
"hookSpecificOutput": { ... }
}
Root Cause and Impact
The echo on line 13 of hooks/core/common.sh writes to stdout instead of stderr. All three hook scripts (pre_tool_use.sh, post_tool_use.sh, post_tool_use_failure.sh) call validate_env_vars before call_gram_api, so every hook invocation prepends this debug text to stdout.
For the standalone install (configured in hooks/install.sh:84-120), hooks are synchronous (no async: true), meaning Claude Code reads stdout to parse the JSON response. The malformed output will cause parse failures for:
- PreToolUse: Could cause the permission decision to fail, potentially blocking all tool execution.
- PostToolUse / PostToolUseFailure: Could cause Claude Code to misinterpret the hook result.
For the plugin (hooks/plugin-claude/hooks/hooks.json), hooks are marked "async": true, so stdout may be ignored — limiting the impact to the standalone install.
The error output in call_gram_api correctly uses >&2 (stderr) at hooks/core/common.sh:103-105, showing the intent was to keep stdout clean for JSON.
| echo "RUNNING HOOK $hook_event_name" | |
| echo "RUNNING HOOK $hook_event_name" >&2 |
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Found 6 test failures on Blacksmith runners: Failures
|
An initial pass at Hooks. Pending further testing and productionization work