fix(matrix): keep HTTP error and tool-progress truncations UTF-16 safe#102395
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 1:12 AM ET / 05:12 UTC. Summary PR surface: Source +2, Tests +33. Total +35 across 4 files. Reproducibility: yes. source-reproducible: current main uses raw UTF-16 slicing at both Matrix truncation boundaries, and the revised tests now place surrogate pairs exactly on the truncation boundary. I did not run a live Matrix homeserver path in this read-only review. 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: Merge the narrow helper-based Matrix fix after the contributor adds redacted after-fix Matrix runtime or production-path terminal proof. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main uses raw UTF-16 slicing at both Matrix truncation boundaries, and the revised tests now place surrogate pairs exactly on the truncation boundary. I did not run a live Matrix homeserver path in this read-only review. Is this the best way to solve the issue? Yes for the code shape: reusing the existing UTF-16-safe SDK helper inside the Matrix plugin is the narrow owner-boundary fix and does not add config, protocol, or public API surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 624dfa6cf6dc. Label changesLabel justifications:
Evidence reviewedPR surface: Source +2, Tests +33. Total +35 across 4 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 (2 earlier review cycles) |
|
Land-ready proof for exact head
The reviewed implementation is the best bounded fix: existing limits and behavior remain intact, both Matrix owner paths now use the canonical helper, and no new config or compatibility path is introduced. |
|
Merged via squash.
|
|
Thanks @steipete — appreciated. This PR closes the last remaining gap in the Matrix plugin for the 2026-07 UTF-16 safe truncation wave: the 3 text-truncation sites in |
openclaw#102395) * fix(matrix): keep HTTP error and tool-progress truncations UTF-16 safe * test(matrix): prove UTF-16 truncation boundaries --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Matrix truncates HTTP error bodies and long tool-progress lines by UTF-16 code-unit offsets. A raw
String.prototype.slicecan stop after the high surrogate of an astral character, leaving malformed text for logs and chat rendering.Why This Change Was Made
Both Matrix-owned boundaries now use the existing
truncateUtf16Safehelper fromopenclaw/plugin-sdk/text-utility-runtime:buildHttpErrorkeeps its 500-unit cap for parsed responses without a usableerrorand for invalid JSON bodies....suffix.The implementation stays inside the Matrix plugin and does not change config, protocol, public APIs, or normal short-text behavior.
User Impact
Long Matrix HTTP errors and configured long progress lines no longer acquire a dangling surrogate when an emoji crosses the truncation boundary. ASCII, BMP-only text, and text below the existing limits remain unchanged.
Evidence
maxLineChars: 500, which makes the Matrix-owned 299-unit cap reachable after shared progress compaction.node scripts/run-vitest.mjs extensions/matrix/src/matrix/sdk/event-helpers.test.ts extensions/matrix/src/matrix/monitor/handler.test.ts— 2 files, 126 tests passed.git diff --check— passed.The earlier submitted fixtures did not cross their claimed boundaries: one contained a complete surrogate pair inside the cap, and the other placed the emoji after the cap. The reviewed head replaces them with exact assertions and covers the previously untested tool-progress owner path.