Commit 3a8201e
committed
fix(hooks): preserve stderr and exitCode in hookResult error paths
When runHook encounters a timeout or handler error, it must preserve
the handler's stderr output and set exitCode to -1 so aggregate can
surface them correctly. The refactoring that embedded HandlerResult
into hookResult inadvertently broke this by returning a zero-valued
HandlerResult (empty stderr, exitCode=0) on error paths.
This is critical for PreToolUse fail-closed semantics: when a hook
fails to execute, aggregate reads r.Stderr to include in the denial
message. Without this fix, the stderr is lost and users see only
"PreToolUse hook failed to execute: <err>" without the underlying
command's diagnostic output.
The fix explicitly constructs HandlerResult{Stderr: res.Stderr,
ExitCode: -1} in both error returns, matching the old behavior where
runHook mutated r.stderr and r.exitCode before returning.
Assisted-By: docker-agent1 parent d27bb33 commit 3a8201e
1 file changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
222 | 225 | | |
223 | 226 | | |
224 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
225 | 231 | | |
226 | 232 | | |
227 | 233 | | |
| |||
0 commit comments