Skip to content

fix: answer Claude Code SessionEnd with a valid response (v0.2.2) - #226

Merged
tupe12334 merged 2 commits into
mainfrom
fix/claude-session-end-response
Oct 4, 2026
Merged

tupe12334 merged 2 commits into
mainfrom
fix/claude-session-end-response

Conversation

@tupe12334

Copy link
Copy Markdown
Member

Problem

In Claude Code, every session end shows:

SessionEnd hook [~/.cargo/bin/steplock] failed: Hook JSON output validation failed — decision: Invalid option: expected one of "approve"|"block"

polyhook 0.1.11 labeled Claude Code's SessionEnd, and SessionStart, as Gemini CLI because the two agents share those event names. steplock therefore answered with Gemini's {"decision":"allow"}, which Claude Code rejects.

Fix

Also: lint ratchet

  • Deny clippy::unnecessary_wraps. validate_dir and run_validate never returned Err, so the Validate arm's "validate failed" branch was unreachable. They now return bool, and the tests were updated.
  • Drop clippy::from_iter_instead_of_collect. Clippy has removed it, so it produced the only remaining warning.

Verified

I replayed real hook payloads captured from Claude Code and Gemini CLI 0.39.1 through this build, which uses the published crates.io 0.1.12:

agent / event before (0.2.1) after
Claude Code SessionEnd {"decision":"allow"} (rejected) {}
Claude Code SessionStart {"decision":"allow"} {}
Claude Code PreToolUse / PostToolUse / Stop / UserPromptSubmit {} {} (PreToolUse stays passive, so no auto-allow)
Gemini CLI SessionStart / SessionEnd {"decision":"allow"} {"decision":"allow"} (unchanged; that's Gemini's format)

cargo fmt --check, clippy --all-targets -D warnings (zero warnings) and cargo test are green.

🤖 Generated with Claude Code

tupe12334 and others added 2 commits October 4, 2026 03:02
polyhook 0.1.11 labeled Claude Code SessionStart/SessionEnd as Gemini CLI,
so steplock answered {"decision":"allow"} and Claude Code reported the
hook as failed on every session end. Require polyhook 0.1.12, which tells
them apart via CLAUDE_PROJECT_DIR (polyhook/polyhook#81). Bump to 0.2.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
validate_dir and run_validate never returned Err, so the Validate arm's
"validate failed" branch was unreachable. Return bool instead. Also drop
clippy::from_iter_instead_of_collect, which clippy has removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tupe12334
tupe12334 merged commit 9178d3d into main Oct 4, 2026
14 checks passed
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.

1 participant