Skip to content

fix(fp-check): use correct JSON response format in stop hooks#129

Open
jonathanreedmevs wants to merge 1 commit intotrailofbits:mainfrom
jonathanreedmevs:fix/fp-check-hook-json-response
Open

fix(fp-check): use correct JSON response format in stop hooks#129
jonathanreedmevs wants to merge 1 commit intotrailofbits:mainfrom
jonathanreedmevs:fix/fp-check-hook-json-response

Conversation

@jonathanreedmevs
Copy link

Summary

  • Stop and SubagentStop hook prompts were instructing Claude to return plain text ('block' or 'approve')
  • Claude Code expects prompt-type hooks to respond with JSON, causing Stop hook error: JSON validation failed on every session end
  • Updated both prompts to respond with {"decision": "block", "reason": "..."} to block, or {} to allow stopping

Root Cause

The hook prompts on line 10 and line 22 ended with:

return 'block' with the specific gaps.
return 'approve'.

Claude Code parses the hook response as JSON. Plain text fails JSON validation, producing the error even though the hook logic itself was correct.

Fix

Replace plain-text return instructions with explicit JSON response format matching the Claude Code stop hook schema (decision field). Bump version to 1.0.1 so installed clients receive the update.

- If ANY bug is missing ANY of these phases or the gate review, return 'block' with the specific gaps.
- If all bugs have complete verification with verdicts, return 'approve'.
- If the conversation is not about fp-check verification at all, return 'approve'.
+ If ANY bug is missing ANY of these phases or the gate review, respond with JSON: {"decision": "block", "reason": "<specific gaps>"}
+ If all bugs have complete verification with verdicts, respond with JSON: {}
+ If the conversation is not about fp-check verification at all, respond with JSON: {}

Same change applies to the SubagentStop prompt on line 22.

Discovery

Bug discovered by Claude while debugging the Stop hook error: JSON validation failed error during active use of the fp-check skill.

Bug Replication

  • Start a Claude Code session with fp-check installed
  • Prompt Claude with anything
  • Confirm Stop hook error: JSON validation failed appears
  • Apply fix, restart session, confirm error is gone

Prompt-type stop hooks must respond with JSON. The previous prompts
instructed Claude to return plain text ('block' or 'approve'), causing
'Stop hook error: JSON validation failed' on every session end.

Updated both Stop and SubagentStop hook prompts to respond with:
- {"decision": "block", "reason": "..."} to prevent stopping
- {} to allow stopping (omitting decision field per Claude Code docs)

Bug discovered by Claude while debugging the JSON validation error
during active use of the fp-check skill.
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

@CLAassistant
Copy link

CLAassistant commented Mar 19, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants