Skip to content

fix(mattermost): use truncateUtf16Safe for log text and error truncation#102681

Closed
lzyyzznl wants to merge 1 commit into
openclaw:mainfrom
lzyyzznl:fix/truncateUtf16Safe-mattermost
Closed

fix(mattermost): use truncateUtf16Safe for log text and error truncation#102681
lzyyzznl wants to merge 1 commit into
openclaw:mainfrom
lzyyzznl:fix/truncateUtf16Safe-mattermost

Conversation

@lzyyzznl

@lzyyzznl lzyyzznl commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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.ts uses raw .slice(0, 300) for error text and .slice(0, 200) for log value truncation. Replacing with truncateUtf16Safe ensures 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

  • Mechanical replacement: .slice(0, N) to truncateUtf16Safe(str, N) for two sites
  • No runtime behavior change for ASCII or valid Unicode input

Generated with Claude Code

@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost size: S labels Jul 9, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:55 AM ET / 10:55 UTC.

Summary
This PR imports truncateUtf16Safe into the Mattermost slash HTTP handler and replaces two raw string truncations in sanitized error/log output.

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: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body has rationale only; it does not include after-fix Mattermost slash-command or runtime-log proof from a real setup, terminal/live output, recording, or redacted logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Real behavior proof is missing: the PR body provides rationale but no live Mattermost slash command, runtime log, terminal transcript, or redacted log artifact showing the patched path after the fix.
  • [P1] A same-diff earlier PR is also open and proof-blocked, so maintainers should avoid parallel duplicate landing until one branch supplies acceptable proof.

Maintainer options:

  1. Decide the mitigation before merge
    Land one narrow branch, this PR or fix(mattermost): keep slash command error truncation UTF-16 safe #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.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No code repair is indicated; the contributor needs to add real behavior proof or a maintainer needs to explicitly override the proof gate and choose one duplicate branch.

Security
Cleared: No concrete security or supply-chain regression was found; the patch preserves the existing secret-redaction order and adds no dependency or execution surface.

Review details

Best 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 changes

Label changes:

  • add P3: This is a low-blast-radius Mattermost diagnostics/log correctness fix with no evidence of a user-blocking workflow.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body has rationale only; it does not include after-fix Mattermost slash-command or runtime-log proof from a real setup, terminal/live output, recording, or redacted logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P3: This is a low-blast-radius Mattermost diagnostics/log correctness fix with no evidence of a user-blocking workflow.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body has rationale only; it does not include after-fix Mattermost slash-command or runtime-log proof from a real setup, terminal/live output, recording, or redacted logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +3. Total +3 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 27 24 +3
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 27 24 +3

What I checked:

Likely related people:

  • eleqtrizit: GitHub commit history shows the Mattermost slash callback validation work that added the sanitizer and slash validation log paths now being changed. (role: introduced behavior; confidence: high; commits: 9c0975c1c20e; files: extensions/mattermost/src/mattermost/slash-http.ts, extensions/mattermost/src/mattermost/slash-http.test.ts)
  • steipete: Recent history shows multiple Mattermost slash-http and normalization-core maintenance commits, including slash validation cache hardening and UTF-16 helper package work. (role: recent area contributor; confidence: high; commits: 20fbb8bd149b, 2f33554ed4f8, b22c36f1125c; files: extensions/mattermost/src/mattermost/slash-http.ts, extensions/mattermost/src/mattermost/slash-http.test.ts, packages/normalization-core/src/utf16-slice.ts)
  • mukhtharcm: CONTRIBUTING.md lists Mattermost as this person's area, making them a relevant routing candidate even though sampled line history points to other recent contributors. (role: listed area owner; confidence: medium; files: CONTRIBUTING.md, extensions/mattermost/src/mattermost/slash-http.ts)
  • hugenshen: Authored the recently merged adjacent Mattermost UTF-16 truncation fix for inbound previews, which shares the same invariant but not this slash-http call site. (role: adjacent contributor; confidence: medium; commits: 1fb6e2890217; files: extensions/mattermost/src/mattermost/monitor.ts, extensions/mattermost/src/mattermost/monitor.inbound-system-event.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 9, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for the fix. This is already covered on current main by #102607, landed as ac71074 with the same two Mattermost slash-command error/log boundaries. Closing this later duplicate.

@steipete steipete closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants