Skip to content

fix: fp-check Stop hooks return JSON instead of plain text#137

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

fix: fp-check Stop hooks return JSON instead of plain text#137
bluzername wants to merge 1 commit intotrailofbits:mainfrom
bluzername:fix/fp-check-stop-hook-json

Conversation

@bluzername
Copy link
Copy Markdown

Problem

The fp-check plugin's Stop and SubagentStop hooks cause "JSON validation failed" error every time Claude Code exits a session. The hooks use type: "prompt" which expects the LLM to return structured JSON, but the prompt instructions tell it to return plain text like 'approve' or 'block'.

I was getting this error on every session exit after installing fp-check and it was confusing because the plugin wasnt even being used in those sessions.

Root Cause

In plugins/fp-check/hooks/hooks.json, both hooks have prompts ending with:

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

But Claude Code expects prompt-type hooks to return valid JSON like:

{"decision": "approve"}

Fix

Updated the return instructions in both hooks to ask for JSON format:

Stop hook (line 10):

return JSON: {"decision": "block", "reason": "<specific gaps>"}
return JSON: {"decision": "approve"}

SubagentStop hook (line 22):
Same pattern.

Also added IMPORTANT: Return valid JSON only, no text outside the JSON object. to both prompts to make sure the LLM doesnt add extra text around the JSON.

Impact

This error happens on EVERY session exit when fp-check is installed, even for sessions that have nothing to do with false positive verification. The fix makes both hooks return proper JSON so Claude Code can parse the response correctly.

Closes #131

Copy link
Copy Markdown

@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 pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

[fp-check] Stop hook returns non-JSON output causing JSON validation error in Claude Code

3 participants