fix(gateway): use truncateUtf16Safe in WebSocket log formatting#102561
Conversation
Replace naive .slice(0, N) with truncateUtf16Safe() at four sites: - formatForLog() error chain display - formatForLog() object message display - formatForLog() string value display - compactPreview() log compaction Prevents surrogate pair splitting in gateway WS console logs. Co-Authored-By: Claude <[email protected]>
|
@steipete WebSocket log formatting fix — 4 truncation sites in |
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 5:44 AM ET / 09:44 UTC. Summary PR surface: Source +1, Tests +17. Total +18 across 2 files. Reproducibility: yes. source-level: current main uses raw Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Use the shared UTF-16 truncation helper in this gateway log helper, keep the new focused tests, and merge only after redacted terminal/log/live output or equivalent validation demonstrates the boundary behavior. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main uses raw Is this the best way to solve the issue? Yes, this is the narrowest maintainable fix because it reuses the existing normalization-core helper at the four local truncation sites and now includes focused gateway regression tests. The remaining gap is runtime proof, not a different code shape. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bb1fa4012ecf. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1, Tests +17. Total +18 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
Review history (1 earlier review cycle)
|
|
Land-ready at exact head Maintainer review added sibling-path coverage for strings, Errors, and message objects plus public event-summary coverage for compact assistant previews. The focused WebSocket log suite passed (4 files, 64 tests), targeted oxfmt and Best-fix verdict: all four arbitrary-value boundaries remain owned by |
|
Merged via squash.
|
…claw#102561) * fix(gateway): use truncateUtf16Safe in WebSocket log formatting Replace naive .slice(0, N) with truncateUtf16Safe() at four sites: - formatForLog() error chain display - formatForLog() object message display - formatForLog() string value display - compactPreview() log compaction Prevents surrogate pair splitting in gateway WS console logs. Co-Authored-By: Claude <[email protected]> * test(gateway): cover UTF-16-safe WebSocket log bounds --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Gateway WebSocket diagnostic previews used raw UTF-16 slices in four paths. A log value containing an emoji at a cutoff could therefore produce an unpaired surrogate in diagnostic output.
Why This Change Was Made
Route all four owned WebSocket log boundaries through the existing
truncateUtf16Safehelper, preserving each current limit and suffix without adding a second policy path.User Impact
Gateway diagnostics remain valid Unicode for string, error, message-object, and compact assistant-event previews.
Evidence
Error, and message-object formatting at the 240-code-unit boundary.Files Changed
src/gateway/ws-log.tstruncateUtf16Safe.src/gateway/ws-log.test.tssrc/gateway/ws-log-events.test.ts🤖 Generated with Claude Code