fix(mattermost): use truncateUtf16Safe for log text and error truncation#102681
fix(mattermost): use truncateUtf16Safe for log text and error truncation#102681lzyyzznl wants to merge 1 commit into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:55 AM ET / 10:55 UTC. Summary PR surface: Source +3. Total +3 across 1 file. Reproducibility: yes. from source inspection: current main slices sanitized Mattermost slash-command strings at fixed UTF-16 code-unit lengths, so a surrogate pair crossing the 300 or 200 boundary can be split. I did not establish a live Mattermost reproduction. 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 one narrow branch, this PR or #102607, after redacted Mattermost slash-command or runtime-log proof demonstrates surrogate-boundary truncation; close the other as duplicate after a proof-positive branch is selected or merged. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: current main slices sanitized Mattermost slash-command strings at fixed UTF-16 code-unit lengths, so a surrogate pair crossing the 300 or 200 boundary can be split. I did not establish a live Mattermost reproduction. Is this the best way to solve the issue? Yes for the code shape: using the existing plugin SDK text helper at the final truncation step is the narrowest maintainable fix and preserves sanitizer ordering and limits. The remaining gap is proof, not a better implementation layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c067802cda3a. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +3. Total +3 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
|
What Problem This Solves
Two
.slice(0, N)truncation sites in the Mattermost slash handler may cut UTF-16 surrogate pairs in half when the log text or error message contains multi-byte characters such as emoji.Why This Change Was Made
extensions/mattermost/src/mattermost/slash-http.tsuses raw.slice(0, 300)for error text and.slice(0, 200)for log value truncation. Replacing withtruncateUtf16Safeensures truncated output is always valid Unicode.User Impact
Truncated error and log text in Mattermost remains valid Unicode at existing size limits. No behavioral changes for ASCII-only content.
Evidence
.slice(0, N)totruncateUtf16Safe(str, N)for two sitesGenerated with Claude Code