Repository navigation
fix(acp-core): never return undefined from stringifyNonErrorCause - #96270
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 24, 2026, 2:21 AM ET / 06:21 UTC. Summary PR surface: Source +2, Tests +19. Total +21 across 2 files. Reproducibility: yes. for the helper-level bug: current main returns Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review detailsBest possible solution: Land the narrow helper fallback with the colocated regression test after ordinary maintainer and CI gates. Do we have a high-confidence way to reproduce the issue? Yes for the helper-level bug: current main returns Is this the best way to solve the issue? Yes. The helper owns the AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a96418c65f8f. Label changesLabel justifications:
Evidence reviewedPR surface: Source +2, Tests +19. Total +21 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
5d4a108 to
cc18f71
Compare
`stringifyNonErrorCause` is typed `string`, but its `try` returned `JSON.stringify(value)`, which is `undefined` for functions, symbols, and undefined causes — leaking undefined to callers that format nested ACP runtime failures and expect a string. Fall back to a tag string when stringify yields undefined, matching the already-correct sibling at `src/infra/errors.ts`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cc18f71 to
4f20386
Compare
|
Merged via squash.
|
…enclaw#96270) `stringifyNonErrorCause` is typed `string`, but its `try` returned `JSON.stringify(value)`, which is `undefined` for functions, symbols, and undefined causes — leaking undefined to callers that format nested ACP runtime failures and expect a string. Fall back to a tag string when stringify yields undefined, matching the already-correct sibling at `src/infra/errors.ts`. Co-authored-by: ly-wang19 <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Summary
stringifyNonErrorCause(packages/acp-core/src/error-format.ts) is declared to returnstring, but itstrybody returnedJSON.stringify(value)directly.JSON.stringifyreturnsundefined(not a string) for functions, symbols, andundefined, so the helper leakedundefinedto callers that format nested ACP runtime failure causes and rely on a string (concatenation,.length, etc.).The sibling helper at
src/infra/errors.tsalready guards this exact case with?? Object.prototype.toString.call(value); this aligns acp-core with it.Changes
error-format.ts—return JSON.stringify(value) ?? Object.prototype.toString.call(value);.error-format.test.ts— new colocated test that a function/symbol/undefined cause yields a string, and ordinary causes are unchanged.Real behavior proof
Behavior addressed: a non-Error cause that
JSON.stringifycannot serialize (function/symbol/undefined) madestringifyNonErrorCausereturnundefineddespite itsstringtype. After the fix it returns a tag string; ordinary causes are unchanged.Real environment tested: Node 22.22.1, macOS, no network/model. Vitest exercises the real exported
stringifyNonErrorCausewith constructed inputs. BEFORE isorigin/main'serror-format.ts(swapped in viagit show).Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix: the three unserializable causes now return a string instead of
undefined; object/string/number/null causes are byte-identical. The new test fails onorigin/mainand passes after.What was not tested: end-to-end ACP runtime failure formatting (the test drives the real exported helper that those paths call). No other behavior is touched.
Additional checks
node scripts/run-vitest.mjs packages/acp-core/src/error-format.test.tspasses; fail-before verified by swapping inorigin/main's file.oxlint --tsconfigclean.