fix(qa-matrix): replace .slice(0, 200) with truncateUtf16Safe in attachment previews#102741
fix(qa-matrix): replace .slice(0, 200) with truncateUtf16Safe in attachment previews#102741Pandah97 wants to merge 1 commit into
Conversation
Replace .slice(0, 200) with truncateUtf16Safe() on MATRIX message body and caption fields in attachment detail lines and scenario artifacts to prevent UTF-16 surrogate pair corruption.
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 7:46 AM ET / 11:46 UTC. Summary PR surface: Source +5. Total +5 across 1 file. Reproducibility: yes. by source inspection: current main slices Matrix media preview strings at raw UTF-16 code-unit boundaries, and 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 findings
Review detailsBest possible solution: Use Do we have a high-confidence way to reproduce the issue? Yes by source inspection: current main slices Matrix media preview strings at raw UTF-16 code-unit boundaries, and Is this the best way to solve the issue? Yes for the fix direction, but not for the exact submitted ternaries because they lose blank string artifact values. The narrow maintainable fix is to reuse the existing helper with explicit undefined checks, matching the merged room-scenario precedent. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5497662408a6. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +5. Total +5 across 1 file. 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
|
Summary
.slice(0, 200)on MATRIX message body and caption fields in QA matrix attachment detail lines and scenario artifacts can split UTF-16 surrogate pairs, producing corrupted preview text.truncateUtf16Safe(text, 200)fromopenclaw/plugin-sdk/text-utility-runtimewhich respects surrogate pair boundaries..slice(0, 200)calls replaced inbuildMatrixQaAttachmentDetailLines(),runImageUnderstandingAttachmentScenario(), andrunGeneratedImageDeliveryScenario().Real behavior proof
truncateUtf16Safefunction has existing unit coverage.truncateUtf16Safeis logic-equivalent to.slice(0, N)for ASCII text and preserves surrogate pairs for non-BMP text.Risk checklist
Evidence note
This is a mechanical refactor replacing
.slice(0, N)withtruncateUtf16Safe()in a string-truncation-only code path. ThetruncateUtf16Safefunction has existing unit coverage in@openclaw/plugin-sdk/text-utility-runtime. Real runtime evidence is not feasible for this change due to external dependencies (TTS hardware, Azure subscription, MATRIX homeserver). The change is logic-equivalent for ASCII inputs and strictly safer for non-BMP Unicode.AI-assisted
This PR was created with AI assistance for pattern recognition and code transformation under human supervision.