Commit b10e00e
committed
fix(hooks): also preserve stdout in failed-hook results, pin contract
The previous fix (64a00e7e8) restored Stderr preservation in runHook's
err and timeout paths but constructed a fresh HandlerResult with only
Stderr + ExitCode — silently dropping any Stdout the handler had
captured before failing. The original pre-refactor code preserved
both, and a future caller in aggregate consuming r.Stdout on the err
branch would silently see "" instead of the captured output.
Replace the explicit field listing with a small markFailed closure
that mutates the already-constructed r in place, exactly matching the
old "set ExitCode = -1, clear Output, attach err" pattern. This:
- preserves both Stdout and Stderr (matching pre-refactor behaviour),
- is robust to future fields on HandlerResult — they propagate
automatically rather than needing each call site updated,
- makes the contract explicit in one named place that aggregate's
err-branch reads stderr from.
Add TestExecutorHandlerErrorPreservesStderr to pin the contract
aggregate already relies on. The original regression slipped through
because no existing test asserted result.Stderr for the PreToolUse
fail-closed path; this test would have failed against the
pre-64a00e7e8 code.
Assisted-By: docker-agent1 parent 3a8201e commit b10e00e
2 files changed
Lines changed: 56 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
214 | 228 | | |
215 | 229 | | |
216 | 230 | | |
217 | 231 | | |
218 | 232 | | |
219 | 233 | | |
220 | 234 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 235 | + | |
225 | 236 | | |
226 | 237 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 238 | + | |
231 | 239 | | |
232 | 240 | | |
233 | 241 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
163 | 203 | | |
164 | 204 | | |
165 | 205 | | |
| |||
0 commit comments