fix(agents): keep provider error detail truncation UTF-16 safe#102496
Conversation
Replace the raw detail.slice(0, limit - 1) in truncateErrorDetail with truncateUtf16Safe so provider error previews do not emit lone surrogates when an emoji falls on the truncation boundary. Adds a regression test that places an emoji at the default truncation boundary and asserts the formatted detail contains no lone surrogates. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Codex review: needs changes before merge. Reviewed July 9, 2026, 3:18 AM ET / 07:18 UTC. Summary PR surface: Source +1, Tests +33. Total +34 across 2 files. Reproducibility: yes. source-level: current main truncates provider error detail with raw 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:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep the existing helper-based production fix, clean up the new fixture so lint passes, then rerun focused provider-error coverage and exact-head CI before merge. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main truncates provider error detail with raw Is this the best way to solve the issue? Yes after the lint fix: reusing the existing Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3e787f318785. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1, Tests +33. Total +34 across 2 files. View PR surface stats
Acceptance criteria:
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
|
|
Maintainer verification complete for exact head What I checked:
The earlier Real behavior proof check ran before this maintainer evidence existed; the native landing gate accepted the exact head after the evidence and review artifacts were completed. No docs or changelog change is required for this internal diagnostic-correctness fix. |
|
Merged via squash.
|
…law#102496) * fix(agents): keep provider error detail truncation UTF-16 safe Replace the raw detail.slice(0, limit - 1) in truncateErrorDetail with truncateUtf16Safe so provider error previews do not emit lone surrogates when an emoji falls on the truncation boundary. Adds a regression test that places an emoji at the default truncation boundary and asserts the formatted detail contains no lone surrogates. Co-Authored-By: Claude Opus 4.8 <[email protected]> * test(agents): prove provider error UTF-16 boundary --------- Co-authored-by: chengzhichao-xydt <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Summary
truncateErrorDetailinsrc/agents/provider-http-errors.tsused rawdetail.slice(0, limit - 1)to produce provider error previews. When an emoji (a UTF-16 surrogate pair) sits exactly on the boundary, this leaves a dangling high surrogate. Replace it withtruncateUtf16Safeso provider error messages stay surrogate-safe.Changes
provider-http-errors.ts: importtruncateUtf16Safeand use it for error detail truncation.provider-http-errors.test.ts: add regression test that places 😀 at the default 220-char boundary and asserts no lone surrogates.Real behavior proof
Fixture:
"a".repeat(218) + "😀" + "suffix"with defaultlimit=220.Test
Notes
provider-http-errors.tsfor UTF-16 hardening.🤖 Generated with Claude Code