fix(slack): keep inbound message preview truncation surrogate-safe#102514
fix(slack): keep inbound message preview truncation surrogate-safe#102514zw-xysk wants to merge 2 commits into
Conversation
Slack message preview text is truncated at 160 chars using .slice(0, 160) before being added to the inbound message context. When the truncation boundary falls inside a UTF-16 surrogate pair (emoji, CJK extended), the resulting string contains a dangling surrogate that can corrupt the prompt context. Replace .slice(0, 160) with truncateUtf16Safe(text, 160) so the truncation point always falls on a complete code-point boundary.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close because this PR repeats the same PreparedSlackMessage.preview-only Slack patch that a maintainer already closed in #101784 after deciding that field has no production consumer; the current branch adds a narrower test but does not change that product boundary. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Leave the preview-only branch closed and target any remaining user-visible Slack UTF-16 issue at the maintainer-approved Slack label/message boundary instead. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Leave the preview-only branch closed and target any remaining user-visible Slack UTF-16 issue at the maintainer-approved Slack label/message boundary instead. Do we have a high-confidence way to reproduce the issue? Yes for the internal string behavior: current main's Is this the best way to solve the issue? No. Although the helper is technically suitable, changing only Security review: Security review cleared: The diff imports an existing SDK text helper and adds a focused test; it does not change dependencies, workflows, secrets, permissions, or package resolution. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 769878303744. |
|
🦞✅ Reason: structured ClawSweeper close marker: close-required (sha=5817f8f30031635d2546be4227efb317204cfbea) Closed:
|
|
@steipete hi, quick question about this PR. #102514 fixes a truncation safety issue in the I noticed that Could you confirm whether this field truly has no consumer? If it does have a potential use path, the fix is just 1 line and would complete the sweep of this module. Happy to close it if not. Thanks! |
What Problem This Solves
prepare.tstruncates Slack message preview text at 160 chars using.slice(0, 160)before adding it to the inbound message context. When the truncation boundary falls inside a UTF-16 surrogate pair (emoji like 🎉, CJK extended characters), the resulting string contains a dangling surrogate that can corrupt the LLM prompt context.Changes
extensions/slack/src/monitor/message-handler/prepare.ts(+2, −1):truncateUtf16Safefromopenclaw/plugin-sdk/text-utility-runtimerawBody.slice(0, 160)→truncateUtf16Safe(rawBody, 160)Evidence
Unit tests (113/113 passed):
Real behavior proof (platinum):
Review