From b180351542e9d93f0f9f6d0b6d6c8e0f6f57c37a Mon Sep 17 00:00:00 2001 From: Taylor Mullen Date: Tue, 10 Feb 2026 10:36:09 -0800 Subject: [PATCH] fix(hooks): treat all non-zero exit codes except 1 as blocking --- integration-tests/hooks-system.test.ts | 2 +- packages/core/src/hooks/hookRunner.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/integration-tests/hooks-system.test.ts b/integration-tests/hooks-system.test.ts index 4e27865702..ae8788de51 100644 --- a/integration-tests/hooks-system.test.ts +++ b/integration-tests/hooks-system.test.ts @@ -102,7 +102,7 @@ describe('Hooks System Integration', () => { 'stderr_block_hook.cjs', ` process.stderr.write('File writing blocked by security policy'); -process.exit(101); +process.exit(2); `, ); diff --git a/packages/core/src/hooks/hookRunner.ts b/packages/core/src/hooks/hookRunner.ts index 0809879c72..22391b7ceb 100644 --- a/packages/core/src/hooks/hookRunner.ts +++ b/packages/core/src/hooks/hookRunner.ts @@ -460,18 +460,18 @@ export class HookRunner { decision: 'allow', systemMessage: text, }; - } else if (exitCode === EXIT_CODE_BLOCKING_ERROR) { - // Blocking error - return { - decision: 'deny', - reason: text, - }; - } else { - // Non-blocking error (EXIT_CODE_NON_BLOCKING_ERROR or any other code) + } else if (exitCode === EXIT_CODE_NON_BLOCKING_ERROR) { + // Non-blocking error (EXIT_CODE_NON_BLOCKING_ERROR = 1) return { decision: 'allow', systemMessage: `Warning: ${text}`, }; + } else { + // All other non-zero exit codes (including 2) are blocking + return { + decision: 'deny', + reason: text, + }; } } }