fix: gracefully handle missing input fields in hook handlers (#1098)
The summarize (Stop) and observation (PostToolUse) handlers throw blocking errors (exit code 2) when optional input fields like transcriptPath, toolName, or cwd are missing. This causes visible hook errors on every session stop and after some tool uses. Replace throws with graceful returns matching the existing pattern used for worker-unavailable checks. Fixes #1097 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,8 @@ export const observationHandler: EventHandler = {
|
||||
const { sessionId, cwd, toolName, toolInput, toolResponse } = input;
|
||||
|
||||
if (!toolName) {
|
||||
throw new Error('observationHandler requires toolName');
|
||||
// No tool name provided - skip observation gracefully
|
||||
return { continue: true, suppressOutput: true, exitCode: HOOK_EXIT_CODES.SUCCESS };
|
||||
}
|
||||
|
||||
const port = getWorkerPort();
|
||||
|
||||
Reference in New Issue
Block a user