fix(hooks): treat all non-zero exit codes except 1 as blocking

This commit is contained in:
Taylor Mullen
2026-02-10 10:36:09 -08:00
parent edba8ddfc0
commit b180351542
2 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -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);
`,
);
+8 -8
View File
@@ -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,
};
}
}
}