Conversation
公式Claude Code hooks仕様に合わせてテスト期待値を更新: - エラー時のdecision: "block" → "" (allow stop)に変更 - コマンド失敗、JSON不正、不正decision値、reason未指定をallowに - テスト名から"fail-safe block"を削除してallowを明示 - TestExecuteStopAndSubagentStopHook_FailingCommandReturnsExit2を TestExecuteStopAndSubagentStopHook_FailingCommandAllowsStopに改名
公式Claude Code hooks仕様に合わせた修正: - エラー時(コマンド失敗、JSON不正、バリデーション失敗)のdecision: "block" → decision: "" (allow stop)に変更 - エラー情報はsystemMessageとstderrに記録して観測性を維持 - ntfyなど通知コマンドが失敗してもClaudeが停止できるようになる 参照: 公式仕様ではhookエラーはnon-blocking errorとして扱われる types.go:353 `// "block" only; omit field to allow stop`
hooks_execute.goとmain.goのエラー回復処理を公式仕様に合わせて修正: - アクションエラー集約時: finalOutput.Decision="block"を削除(Decisionを変更しない) - nil output時: Decision/Reasonを設定せずSystemMessageのみ記録 - Marshal失敗時: Decision/Reasonを設定せずSystemMessageのみ記録 公式仕様ではhookエラーはnon-blocking error(stopを許可)として扱われる
CLAUDE.mdのStop/SubagentStop節のエラー時挙動説明を修正: - "decision defaults to block (fail-safe)" → "decision is omitted (allow stop)" - 公式Claude Code仕様ではhookエラーはnon-blocking errorとして扱われることを明記
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
概要
Stop/SubagentStop hookのエラー時fail-safeを
decision: "block"からdecision: ""(allow stop) に変更しました。公式Claude Code hooks仕様に合わせた修正です。背景
Stop hookでntfyによる通知コマンドを使用していた際、環境変数の設定ミスでコマンドが失敗し続けた。従来のfail-safe挙動(エラー時 →
decision: "block")により、Claudeが永遠に停止できなくなる実害が発生していた。公式Claude Code hooks仕様では、hookエラーは「non-blocking error」として扱われ、stopを許可する設計になっている(
types.go:353// "block" only; omit field to allow stop)。変更内容
executor.go: ExecuteStopAction/ExecuteSubagentStopActionの全エラーケース(各7箇所)でDecision: "block"→Decision: ""に変更hooks_execute.go: executeStopHooks/executeSubagentStopHooksのアクションエラー集約時にfinalOutput.Decision = "block"を削除main.go: Stop/SubagentStopのtop-level error recovery(nil output、非nil output、Marshal失敗)でDecision/Reasonを削除しSystemMessageのみ記録executor_test.go,hooks_execute_test.go,actions_test.go: エラーケースの期待値を"block"→""に更新、テスト名を更新CLAUDE.md: Stop/SubagentStop節のエラー時挙動説明を更新エラー情報はstderrとsystemMessageに引き続き記録されるため、運用上の観測性は維持されます。