Skip to content

fix(mattermost): keep slash command error truncation UTF-16 safe#102607

Merged
steipete merged 2 commits into
openclaw:mainfrom
Pandah97:fix/slash-http-truncate-utf16
Jul 9, 2026
Merged

fix(mattermost): keep slash command error truncation UTF-16 safe#102607
steipete merged 2 commits into
openclaw:mainfrom
Pandah97:fix/slash-http-truncate-utf16

Conversation

@Pandah97

@Pandah97 Pandah97 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Mattermost slash-command fallback logs bound untrusted command IDs and upstream error text with raw UTF-16 slicing. An emoji crossing the 200- or 300-code-unit boundary could leave a dangling surrogate in logs.

Why This Change Was Made

Apply the shared truncateUtf16Safe primitive after the existing newline and secret sanitization. The sanitizer remains one canonical path and keeps its existing redaction order and limits.

User Impact

Mattermost slash-command diagnostics remain valid Unicode without exposing more data. Command validation, fallback behavior, redaction, rate limiting, HTTP responses, and configuration are unchanged.

Evidence

  • node ../../node_modules/vitest/vitest.mjs run --config test/vitest/vitest.extension-mattermost.config.ts extensions/mattermost/src/mattermost/slash-http.test.ts — 22 passed
  • exact public-path log assertions at both UTF-16 boundaries
  • existing URL/token redaction assertions retained
  • oxfmt, focused oxlint, git diff --check
  • fresh branch autoreview: clean, no actionable findings

No live Mattermost server is needed because network requests, validation decisions, and emitted log fields are unchanged; the focused tests exercise the real lookup/fallback paths.

Risk

Low. Presentation-only error formatting; no API, config, dependency, or persistence changes. Production LOC decreases relative to main.

AI-assisted

Initial patch generated with Claude Code; maintainer review simplified the sanitizer and added public-path regression coverage.

Replace `.slice(0, 300)` and `.slice(0, 200)` with `truncateUtf16Safe`
in sanitizeCommandLookupError and sanitizeMattermostLogValue to prevent
surrogate pair corruption.

Ref. lsr911 pattern — mechanical substitution, no behavior change.
@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, 7:13 AM ET / 11:13 UTC.

Summary
The PR replaces two Mattermost slash-command diagnostic truncations with truncateUtf16Safe and adds focused slash-http tests for surrogate-boundary log output.

PR surface: Source +1, Tests +32. Total +33 across 2 files.

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.

Root-cause cluster
Relationship: canonical
Canonical: #102607
Summary: This PR is the stronger canonical branch for the Mattermost slash-http UTF-16 truncation fix because it covers the same runtime change as the duplicate and adds focused tests, but it still needs real behavior proof before merge.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦞 diamond lobster
Result: blocked until real behavior proof from a real setup 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: Mock-only: the PR body lists focused Vitest and static checks but no after-fix Mattermost slash-command run, runtime log, terminal/live output, recording, or redacted log artifact; the contributor should add proof with private data redacted and update the PR body to trigger re-review.

Risk before merge

  • [P1] Real behavior proof is still absent: the PR body provides focused tests and static checks, but no after-fix Mattermost slash-command run, runtime log, terminal/live output, recording, or redacted log artifact shows the patched path.
  • [P1] fix(mattermost): use truncateUtf16Safe for log text and error truncation #102681 is an open same-surface duplicate, so maintainers should land only one proof-positive branch.

Maintainer options:

  1. Decide the mitigation before merge
    Land one narrow Mattermost slash-http truncation fix after redacted real runtime proof demonstrates surrogate-boundary diagnostics, then close the duplicate branch.
  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 remaining action is contributor real behavior proof or maintainer proof override plus duplicate-branch selection.

Security
Cleared: No concrete security or supply-chain regression was found; the patch preserves existing redaction order and adds no dependencies, workflows, permissions, or execution surfaces.

Review details

Best possible solution:

Land one narrow Mattermost slash-http truncation fix after redacted real runtime proof demonstrates surrogate-boundary diagnostics, then close the duplicate branch.

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 real behavior proof, not a better implementation layer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5ba981a4370d.

Label changes

Label justifications:

  • P3: This is a low-blast-radius Mattermost diagnostics/log correctness fix with no evidence of a user-blocking workflow or compatibility impact.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Mock-only: the PR body lists focused Vitest and static checks but no after-fix Mattermost slash-command run, runtime log, terminal/live output, recording, or redacted log artifact; the contributor should add proof with private data redacted and update the PR body to trigger re-review.
Evidence reviewed

PR surface:

Source +1, Tests +32. Total +33 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 4 +1
Tests 1 36 4 +32
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 41 8 +33

What I checked:

Likely related people:

  • eleqtrizit: Authored the Mattermost slash callback validation PR that added much of the slash validation path now being patched. (role: introduced behavior; confidence: high; commits: 9c0975c1c20e, 5a2915a5e815; files: extensions/mattermost/src/mattermost/slash-http.ts, extensions/mattermost/src/mattermost/slash-http.test.ts)
  • drobison00: Authored the slash validation error redaction commit and merged the Mattermost slash callback validation PR containing the sanitizer path. (role: redaction path contributor and merger; confidence: high; commits: 6857b658d893, 9c0975c1c20e; files: extensions/mattermost/src/mattermost/slash-http.ts, extensions/mattermost/src/mattermost/slash-http.test.ts)
  • steipete: Recent history shows Mattermost slash-http maintenance and the current PR's test commit, plus related normalization-helper maintenance. (role: recent area contributor; confidence: high; commits: 20fbb8bd149b, 2f33554ed4f8, 4138d7c0c0e8; 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 file history points to other 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-09T09:37:27.053Z sha 68b5c8a :: needs real behavior proof before merge. :: none

@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

Land-ready review complete on exact head 4138d7c0c0e83ff7d44c82fe91774441096ef4cf.

  • Refactored Mattermost slash-command HTTP error logging so redaction remains before the shared UTF-16-safe 200-unit bound.
  • Applied the same boundary to the generic Mattermost log-value sanitizer.
  • Added exact public-path assertions at the 200- and 300-unit boundaries while retaining the existing secret-redaction coverage.
  • Focused Mattermost slash-command suite: 22 passed.
  • Static proof: focused oxfmt, oxlint, git diff --check; fresh autoreview clean (0.98).
  • CI recovery: the first build-artifacts job lost its runner mid-build without a retrievable log; the failed-only rerun passed. Exact-head hosted CI/Testbox now has 58 relevant checks passing.
  • Native prepare gate passed; remote PR head tree matches the prepared tree.

No docs or changelog entry is required because this only repairs bounded, redacted diagnostics.

@steipete
steipete merged commit ac71074 into openclaw:main Jul 9, 2026
154 of 161 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
…nclaw#102607)

* fix(mattermost): keep slash command error truncation UTF-16 safe

Replace `.slice(0, 300)` and `.slice(0, 200)` with `truncateUtf16Safe`
in sanitizeCommandLookupError and sanitizeMattermostLogValue to prevent
surrogate pair corruption.

Ref. lsr911 pattern — mechanical substitution, no behavior change.

* test(mattermost): cover UTF-16-safe slash logs

Co-authored-by: 黄剑雄0668001315 <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
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: XS 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