fix(whatsapp): keep echo tracker log truncation UTF-16 safe#102603
Conversation
Replace `.slice(0, 50)` with `truncateUtf16Safe(text, 50)` in echo tracker verbose log message to prevent surrogate pair corruption. Ref. lsr911 pattern — mechanical substitution, no behavior change.
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:39 AM ET / 10:39 UTC. Summary PR surface: Source +1, Tests +18. Total +19 across 2 files. Reproducibility: yes. by source inspection and a focused JavaScript probe: current main uses 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: Land the helper substitution and regression test once the proof gate is satisfied, while keeping echo matching, storage, limits, and delivery behavior unchanged. Do we have a high-confidence way to reproduce the issue? Yes, by source inspection and a focused JavaScript probe: current main uses Is this the best way to solve the issue? Yes for the code shape: the owner-local verbose preview should reuse the existing plugin-SDK AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b8c1b220e498. Label changesLabel justifications:
Evidence reviewedPR surface: Source +1, Tests +18. Total +19 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 proof for exact head
No live send is needed because transport, delivery, and echo identity are unchanged; this is isolated verbose-log formatting. No changelog entry or known proof gaps. |
|
Merged via squash.
|
…#102603) * fix(whatsapp): keep echo tracker log truncation UTF-16 safe Replace `.slice(0, 50)` with `truncateUtf16Safe(text, 50)` in echo tracker verbose log message to prevent surrogate pair corruption. Ref. lsr911 pattern — mechanical substitution, no behavior change. * test(whatsapp): cover UTF-16-safe echo previews --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
WhatsApp's echo tracker included the first 50 UTF-16 code units of a sent message in verbose diagnostics using raw
.slice(0, 50). An emoji or another supplementary Unicode character crossing that boundary left a dangling surrogate in the log preview.Why This Change Was Made
The WhatsApp-owned logger now uses the existing plugin-SDK
truncateUtf16Safehelper at the same 50-code-unit bound. The regression test drives the public echo-tracker behavior, places an emoji across the exact boundary, asserts the complete log message, and verifies that the unmodified full text remains in the echo-detection set.User Impact
Verbose WhatsApp diagnostics stay valid and readable for emoji-bearing messages. Echo matching, storage, limits, configuration, and message delivery are unchanged.
Evidence
node ../../node_modules/vitest/vitest.mjs run --config test/vitest/vitest.extension-whatsapp.config.ts extensions/whatsapp/src/auto-reply/monitor/echo.test.ts— 1 test passed.oxfmt, focusedoxlint, andgit diff --checkpassed for the touched files.No external WhatsApp call is required for this isolated verbose-log formatting path; the channel transport and delivery path are not changed.
AI-assisted
This PR was generated with Claude Code and improved/reviewed with Codex.