Skip to content

fix(mattermost): let buttons with Chinese, spaced or agent-callback values be clicked - #206228

Merged
obviyus merged 3 commits into
openclaw:mainfrom
hannnnn-l:fix/mattermost-action-id
Nov 27, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
hannnnn-l:fix/mattermost-action-id

Conversation

@hannnnn-l

@hannnnn-l hannnnn-l commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Root cause: extensions/mattermost/src/mattermost/interactions.ts:205 (on main) sanitizeActionId stripped only - and _ from the button value it used as the Mattermost action id. Mattermost routes clicks only through /posts/{post_id}/actions/{action_id:[A-Za-z0-9]+}, so any other character returned 404 before OpenClaw saw the click.

Fixes #206226

Thanks @hannnnn-l for the report and the fix.

What Problem This Solves

Clicking a Mattermost button opens "Page not found." when the button's value contains anything other than [A-Za-z0-9], for example a Chinese value like 删掉说明和备注两条帖子,只留表 or one with spaces or punctuation. The click never reaches OpenClaw. Since #201764, every button the agent sends with the message tool breaks this way, even approve, because agent callback values carry the :: mark and that mark ended up in the action id. The mark first shipped in v2026.11.10-beta.3 and v2026.11.10 (current latest). v2026.10.34 (extended-stable) and v2026.11.9 and earlier don't have it, so there only non-alphanumeric values break.

Mattermost keeps the action id the post was created with (server/channels/api4/integration_action.go, v11.7.15).

Why This Change Was Made

buildButtonAttachments is the one place that turns a button id into the Mattermost action id and the signed context.action_id.

  • An id that is already [A-Za-z0-9]+ is used unchanged, so the model picker and raw callers produce byte-identical posts.
  • Any other id becomes <its alphanumerics, max 16>x<button index>. The index after the last x makes derived ids unique within a post by construction, including two values that clean to the same text (yes? / yes!).
  • Accepted edge case, not observed: a raw alphanumeric id that equals a derived id in the same post would clash (Mattermost sends the click to the first action with that id). Agent, question and picker ids can't produce it.
  • The value itself still travels unchanged in the HMAC-signed context.callback_data, which is what the click delivers to the agent. Signing, the post-action match and the click authorization check are unchanged.

The docs no longer say the value is used as the action id, and the 404 troubleshooting entry names the real cause.

User Impact

Buttons with any value work again, and the agent receives the exact original value. Posts already sent with broken ids stay broken and have to be re-sent. No config or migration is needed.

Evidence

Case main this PR
Chinese value 404 "Page not found", no Gateway log, no agent turn 200, agent gets 删掉说明和备注两条帖子,只留表
Spaces/punctuation yes, do it! (now) 404 200, agent gets the exact value
Agent value approve (::approve) 404 200, agent gets approve
Model picker (/oc_models) 200, id mdllistb735d7f3f8da same id, 200
Tampered callback_data or action_id 403 Invalid token 403 Invalid token

Merge danger: two-way door. A revert restores the old ids. Nothing is stored and no config changes. Blast radius is Mattermost button posts.

@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: mattermost Channel integration: mattermost size: XS labels Nov 26, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. labels Nov 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 26, 2026
@clawsweeper

clawsweeper Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR derives alphanumeric Mattermost button action IDs while preserving original callback values in signed context.

Example: An agent sends an Approve button with callback value approve.

  • Before: The action ID becomes ::approve, and Mattermost returns HTTP 404 before contacting OpenClaw.
  • After: The action ID becomes approve2a03482c0 in the supplied example, and the agent receives callback_data: approve.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-verified repair with production-route before/after evidence; broad hosted validation remains unrun.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Supplied terminal and Gateway logs exercise the changed builder through the shipped message action, real Mattermost server and authenticated action route, showing recovery and exact callback delivery for three affected values; browser interaction was not exercised and the model endpoint was mocked. Existing-post compatibility is source-verified: incoming IDs are read from stored posts rather than regenerated, and no stored schema or config changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Mattermost displays Page not found when users click buttons whose generated action IDs contain Chinese text, spaces, punctuation, or the agent callback prefix.
Reason: Restoring routable button IDs fulfills the existing interactive-button contract without adding configuration or a competing owner.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR repairs a current Mattermost routing bug with a focused change and no introduced defects found; required hosted CI has not run.

Reviewed head: 3d78de3c485a3fbae5597857a11fbab23e980d50

Before merge

  • Await maintainer action - Approve the required GitHub Actions workflows for the reviewed head so hosted checks can run.

Findings

None.

Agent review details

How this fits together

The Mattermost plugin converts presentation buttons into posted attachments, then verifies incoming callbacks and dispatches the original values to the conversation.

flowchart LR
  A[Message action] --> B[Mattermost presentation]
  B --> C[Attachment builder]
  C --> D[Mattermost post]
  D --> E[Action route]
  E --> F[Verified callback]
  F --> G[Agent conversation]
Loading

Technical review

Best possible solution:

Land the focused attachment-builder repair after required hosted checks pass, preserving signed callback values and existing-post handling.

Do we have a high-confidence way to reproduce the issue?

The current-main sanitizer and Mattermost's verified route establish the failure path, supported by supplied before/after transport logs; this read-only review did not execute the reproduction.

Is this the best way to solve the issue?

The change repairs the existing producer at the Mattermost encoding boundary, removes the old sanitizer, and preserves the original value independently of the routing ID.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against eb0faf79a5be.

Provenance checked

  • Mattermost action-ID sanitization keeps the original intent (136ca87: The original button feature sanitized IDs to accommodate Mattermost routing; this PR completes that purpose for the full route restriction.)
  • Agent callback ownership and exact values keeps the original intent (fix: agent-authored message buttons reach the agent on every channel #201764: Core marks agent-authored callbacks with :: so channels can deliver their exact values to the agent; this PR keeps that value in signed context.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Tony Dehnke: Raw commit 136ca87 adds extensions/mattermost/src/mattermost/interactions.ts:177 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 136ca87f7bb2; files: extensions/mattermost/src/mattermost/interactions.ts)
  • Ayaan Zaidi: Raw commit cd2ae19 adds extensions/mattermost/src/mattermost/interactions.ts:565 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cd2ae19272a3; files: extensions/mattermost/src/mattermost/interactions.ts)
  • Peter Steinberger: Raw commit 90c6934 adds extensions/mattermost/src/mattermost/interactions.ts:217 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 90c6934d630f; files: extensions/mattermost/src/mattermost/interactions.ts)

PR surface

Source +5, Tests +22, Docs 0. Total +27 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 13 8 +5
Tests 1 23 1 +22
Docs 1 4 4 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 40 13 +27

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #206226
Summary: This PR addresses the canonical routing report; the earlier sanitization attempt did not merge.

Members:

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

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The exported Mattermost attachment builder changes emitted action IDs for non-alphanumeric inputs through a narrow transport-contract repair; alphanumeric IDs, callback values, and the existing-post reader remain compatible.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.

Label justifications:

  • merge-risk: 🚨 compatibility: The exported Mattermost attachment builder changes emitted action IDs for non-alphanumeric inputs through a narrow transport-contract repair; alphanumeric IDs, callback values, and the existing-post reader remain compatible.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 26, 2026, 6:43 PM ET / 23:43 UTC.

Non-alphanumeric ids become <alphanumerics>x<index>, unique per post by construction. A raw alphanumeric id equal to a derived id fails the send instead of misrouting the click.
@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Live proof on throwaway Mattermost 11.7.15 (team edition) with an isolated Gateway built in Docker. Base: aa0268fa72 (main). Fix: 2e5e9f7c81. Values were sent by a scripted model through the real message tool and clicked as user alice through POST /api/v4/posts/{post}/actions/{id}, the route the web app uses. Each side ran twice with the same results; round 1 is shown (ids are from the throwaway server).

[base] button name='B1 删掉说明和备注两条帖子,只留表' id='::删掉说明和备注两条帖子,只留表'
[base] button name='B2 yes, do it! (now)' id='::yes, do it! (now)'
[base] button name='B3 approve' id='::approve'
[base] click 'B1 删掉说明和备注两条帖子,只留表': POST /api/v4/posts/xjon954gz3yd5m5zi5s7y68tec/actions/%3A%3A%E5%88%A0%E6%8E%89%E8%AF%B4%E6%98%8E%E5%92%8C%E5%A4%87%E6%B3%A8%E4%B8%A4%E6%9D%A1%E5%B8%96%E5%AD%90%EF%BC%8C%E5%8F%AA%E7%95%99%E8%A1%A8
[base]   gateway '[mattermost] interaction:' lines: 0
[base]   model turns: 0
[base] click 'B2 yes, do it! (now)': POST /api/v4/posts/ji4quyunf3fbinziy4riismo4y/actions/%3A%3Ayes%2C%20do%20it%21%20%28now%29 -> HTTP 404 {"id": "api.context.404.app_error", "message": "Sorry, we could not find the page.", "detailed_error": "There doesn't a
[base]   gateway '[mattermost] interaction:' lines: 0
[base]   model turns: 0
[base] click 'B3 approve': POST /api/v4/posts/stuhbufx3tgqtny4p9nzwzkm5h/actions/%3A%3Aapprove -> HTTP 404 {"id": "api.context.404.app_error", "message": "Sorry, we could not find the page.", "detailed_error": "There doesn't appear to be an api call for the ur
[base]   gateway '[mattermost] interaction:' lines: 0
[base]   model turns: 0
[base] /oc_models execute -> HTTP 200
[base] model picker ids: ['mdllistb735d7f3f8da']
[base] picker click 'local (1)': POST /api/v4/posts/emufabraqf8dmyrsmbxx4s9gza/actions/mdllistb735d7f3f8da -> HTTP 200; gateway: ['action=mdllistb735d7f3f8da user=alice post=emufabraqf8dmyrsmbxx4s9gza channel=hjy35qthu3f73khw8ux1j9erpy']
[base] tampered callback_data context POST to Gateway callback -> 403 {"error":"Invalid token"}; gateway: ['invalid _token']; model turns: []
[base] tampered action_id context POST to Gateway callback -> 403 {"error":"Invalid token"}; gateway: ['invalid _token']; model turns: []
[base] untampered context POST to Gateway callback -> 200 {}; gateway: ['action=::approve user=alice post=hytxu1ghhpbxdnu65zqq66n43e channel=hjy35qthu3f73khw8ux1j9erpy']; model turn dispatched

[cand] button name='B1 删掉说明和备注两条帖子,只留表' id='x0'
[cand] button name='B2 yes, do it! (now)' id='yesdoitnowx1'
[cand] button name='B3 approve' id='approvex2'
[cand] click 'B1 删掉说明和备注两条帖子,只留表': POST /api/v4/posts/sucxsimoh3rs5dyx3kupzr19bh/actions/x0 -> HTTP 200 {"status": "OK", "trigger_id": "q6s1r1s7kbfrdpaf1pb4snnfkr"}
[cand]   gateway '[mattermost] interaction:' lines: 1
[cand]     action=x0 user=alice post=sucxsimoh3rs5dyx3kupzr19bh channel=hjy35qthu3f73khw8ux1j9erpy
[cand] click 'B2 yes, do it! (now)': POST /api/v4/posts/yawrcesz97gyiq3p1iz7ke99sr/actions/yesdoitnowx1 -> HTTP 200 {"status": "OK", "trigger_id": "3acoqjp7yfgytxd1f58cfb54na"}
[cand]   gateway '[mattermost] interaction:' lines: 1
[cand]     action=yesdoitnowx1 user=alice post=yawrcesz97gyiq3p1iz7ke99sr channel=hjy35qthu3f73khw8ux1j9erpy
[cand] click 'B3 approve': POST /api/v4/posts/jdjkybiurjdumc3kuu4bts5fxh/actions/approvex2 -> HTTP 200 {"status": "OK", "trigger_id": "1bcqto1n4pgwmk1bmqem3heg7a"}
[cand]   gateway '[mattermost] interaction:' lines: 1
[cand]     action=approvex2 user=alice post=jdjkybiurjdumc3kuu4bts5fxh channel=hjy35qthu3f73khw8ux1j9erpy
[cand] /oc_models execute -> HTTP 200
[cand] model picker ids: ['mdllistb735d7f3f8da']
[cand] picker click 'local (1)': POST /api/v4/posts/nihzsa54hjd9zr73m7q8o496fe/actions/mdllistb735d7f3f8da -> HTTP 200; gateway: ['action=mdllistb735d7f3f8da user=alice post=nihzsa54hjd9zr73m7q8o496fe channel=hjy35qthu3f73khw8ux1j9erpy']
[cand] tampered callback_data context POST to Gateway callback -> 403 {"error":"Invalid token"}; gateway: ['invalid _token']; model turns: []
[cand] tampered action_id context POST to Gateway callback -> 403 {"error":"Invalid token"}; gateway: ['invalid _token']; model turns: []
[cand] untampered context POST to Gateway callback -> 200 {}; gateway: ['action=approvex2 user=alice post=tubfsdfew3f4jf87tm6z3iqi3o channel=hjy35qthu3f73khw8ux1j9erpy']; model turn dispatched
[cand-1] click turns the model received: 4
[cand-1]   callback_data: '删掉说明和备注两条帖子,只留表' exact=yes
[cand-1]   callback_data: 'yes, do it! (now)' exact=yes
[cand-1]   callback_data: 'approve' exact=yes
[cand-1]   callback_data: 'approve' exact=yes

[base] ids=mdllistb735d7f3f8da,approve,Yes2 sha256=886d9aed3acc88e692f57c3bc6d044610a8b9b43a05c1c8bc7a799913060df0b
[cand] ids=mdllistb735d7f3f8da,approve,Yes2 sha256=886d9aed3acc88e692f57c3bc6d044610a8b9b43a05c1c8bc7a799913060df0b

alnum-control: built buildButtonAttachments with alphanumeric ids (picker-style and raw) gives byte-identical output on base and fix. The fourth approve turn is the untampered direct callback control.

@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Chromium as alice, clicking the Chinese-value button. Base (main): Mattermost shows "Sorry, we could not find the page." Fix: the click is accepted, the post shows "✓ B1 … selected by @alice", and the agent replies.

base: Sorry, we could not find the page

fix: click accepted, agent replied

A raw alphanumeric id equal to a derived id in one post is an accepted, unobserved edge case; name it in the doc comment instead.
@obviyus
obviyus merged commit be5d9a0 into openclaw:main Nov 27, 2026
99 of 100 checks passed
@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Landed in be5d9a0. Mattermost buttons with Chinese text, spaces, punctuation or agent callback values can be clicked again: Mattermost gets a letters-and-digits action id, and the agent receives the exact original value. Signing, the click authorization and already-alphanumeric ids like the model picker are unchanged. Thanks @hannnnn-l for the report and the fix; we simplified the id scheme in one commit on top and kept yours.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 27, 2026
…alues be clicked (openclaw#206228)

Root cause: extensions/mattermost/src/mattermost/interactions.ts:205 (on main) `sanitizeActionId` stripped only `-` and `_` from the button value it used as the Mattermost action id. Mattermost routes clicks only through `/posts/{post_id}/actions/{action_id:[A-Za-z0-9]+}`, so any other character returned 404 before OpenClaw saw the click.

Fixes openclaw#206226

Thanks @hannnnn-l for the report and the fix.

## What Problem This Solves

Clicking a Mattermost button opens "Page not found." when the button's value contains anything other than `[A-Za-z0-9]`, for example a Chinese value like `删掉说明和备注两条帖子,只留表` or one with spaces or punctuation. The click never reaches OpenClaw. Since openclaw#201764, every button the agent sends with the `message` tool breaks this way, even `approve`, because agent callback values carry the `::` mark and that mark ended up in the action id. The mark first shipped in v2026.11.10-beta.3 and v2026.11.10 (current `latest`). v2026.10.34 (`extended-stable`) and v2026.11.9 and earlier don't have it, so there only non-alphanumeric values break.

Mattermost keeps the action id the post was created with (`server/channels/api4/integration_action.go`, v11.7.15).

## Why This Change Was Made

`buildButtonAttachments` is the one place that turns a button id into the Mattermost action `id` and the signed `context.action_id`.

- An id that is already `[A-Za-z0-9]+` is used unchanged, so the model picker and raw callers produce byte-identical posts.
- Any other id becomes `<its alphanumerics, max 16>x<button index>`. The index after the last `x` makes derived ids unique within a post by construction, including two values that clean to the same text (`yes?` / `yes!`).
- Accepted edge case, not observed: a raw alphanumeric id that equals a derived id in the same post would clash (Mattermost sends the click to the first action with that id). Agent, question and picker ids can't produce it.
- The value itself still travels unchanged in the HMAC-signed `context.callback_data`, which is what the click delivers to the agent. Signing, the post-action match and the click authorization check are unchanged.

The docs no longer say the value is used as the action id, and the 404 troubleshooting entry names the real cause.

## User Impact

Buttons with any value work again, and the agent receives the exact original value. Posts already sent with broken ids stay broken and have to be re-sent. No config or migration is needed.

## Evidence

- Regression test (`interactions.test.ts`): red on main (`expected '::删掉说明和备注两条帖子,只留表' to match /^[A-Za-z0-9]+$/`), green with the fix.
- Live run against Mattermost 11.7.15 with an isolated Gateway built from main and from this head. A scripted model sends a buttons block through the real `message` tool, and user alice clicks through Mattermost's action route, twice per side: openclaw#206228 (comment)
- Chromium screenshots: openclaw#206228 (comment)

| Case | main | this PR |
| --- | --- | --- |
| Chinese value | 404 "Page not found", no Gateway log, no agent turn | 200, agent gets `删掉说明和备注两条帖子,只留表` |
| Spaces/punctuation `yes, do it! (now)` | 404 | 200, agent gets the exact value |
| Agent value `approve` (`::approve`) | 404 | 200, agent gets `approve` |
| Model picker (`/oc_models`) | 200, id `mdllistb735d7f3f8da` | same id, 200 |
| Tampered `callback_data` or `action_id` | 403 Invalid token | 403 Invalid token |

Merge danger: two-way door. A revert restores the old ids. Nothing is stored and no config changes. Blast radius is Mattermost button posts.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…alues be clicked (#206228)

Root cause: extensions/mattermost/src/mattermost/interactions.ts:205 (on main) `sanitizeActionId` stripped only `-` and `_` from the button value it used as the Mattermost action id. Mattermost routes clicks only through `/posts/{post_id}/actions/{action_id:[A-Za-z0-9]+}`, so any other character returned 404 before OpenClaw saw the click.

Fixes #206226

Thanks @hannnnn-l for the report and the fix.

## What Problem This Solves

Clicking a Mattermost button opens "Page not found." when the button's value contains anything other than `[A-Za-z0-9]`, for example a Chinese value like `删掉说明和备注两条帖子,只留表` or one with spaces or punctuation. The click never reaches OpenClaw. Since #201764, every button the agent sends with the `message` tool breaks this way, even `approve`, because agent callback values carry the `::` mark and that mark ended up in the action id. The mark first shipped in v2026.11.10-beta.3 and v2026.11.10 (current `latest`). v2026.10.34 (`extended-stable`) and v2026.11.9 and earlier don't have it, so there only non-alphanumeric values break.

Mattermost keeps the action id the post was created with (`server/channels/api4/integration_action.go`, v11.7.15).

## Why This Change Was Made

`buildButtonAttachments` is the one place that turns a button id into the Mattermost action `id` and the signed `context.action_id`.

- An id that is already `[A-Za-z0-9]+` is used unchanged, so the model picker and raw callers produce byte-identical posts.
- Any other id becomes `<its alphanumerics, max 16>x<button index>`. The index after the last `x` makes derived ids unique within a post by construction, including two values that clean to the same text (`yes?` / `yes!`).
- Accepted edge case, not observed: a raw alphanumeric id that equals a derived id in the same post would clash (Mattermost sends the click to the first action with that id). Agent, question and picker ids can't produce it.
- The value itself still travels unchanged in the HMAC-signed `context.callback_data`, which is what the click delivers to the agent. Signing, the post-action match and the click authorization check are unchanged.

The docs no longer say the value is used as the action id, and the 404 troubleshooting entry names the real cause.

## User Impact

Buttons with any value work again, and the agent receives the exact original value. Posts already sent with broken ids stay broken and have to be re-sent. No config or migration is needed.

## Evidence

- Regression test (`interactions.test.ts`): red on main (`expected '::删掉说明和备注两条帖子,只留表' to match /^[A-Za-z0-9]+$/`), green with the fix.
- Live run against Mattermost 11.7.15 with an isolated Gateway built from main and from this head. A scripted model sends a buttons block through the real `message` tool, and user alice clicks through Mattermost's action route, twice per side: #206228 (comment)
- Chromium screenshots: #206228 (comment)

| Case | main | this PR |
| --- | --- | --- |
| Chinese value | 404 "Page not found", no Gateway log, no agent turn | 200, agent gets `删掉说明和备注两条帖子,只留表` |
| Spaces/punctuation `yes, do it! (now)` | 404 | 200, agent gets the exact value |
| Agent value `approve` (`::approve`) | 404 | 200, agent gets `approve` |
| Model picker (`/oc_models`) | 200, id `mdllistb735d7f3f8da` | same id, 200 |
| Tampered `callback_data` or `action_id` | 403 Invalid token | 403 Invalid token |

Merge danger: two-way door. A revert restores the old ids. Nothing is stored and no config changes. Blast radius is Mattermost button posts.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit be5d9a0)
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…alues be clicked (#206228)

Root cause: extensions/mattermost/src/mattermost/interactions.ts:205 (on main) `sanitizeActionId` stripped only `-` and `_` from the button value it used as the Mattermost action id. Mattermost routes clicks only through `/posts/{post_id}/actions/{action_id:[A-Za-z0-9]+}`, so any other character returned 404 before OpenClaw saw the click.

Fixes #206226

Thanks @hannnnn-l for the report and the fix.

## What Problem This Solves

Clicking a Mattermost button opens "Page not found." when the button's value contains anything other than `[A-Za-z0-9]`, for example a Chinese value like `删掉说明和备注两条帖子,只留表` or one with spaces or punctuation. The click never reaches OpenClaw. Since #201764, every button the agent sends with the `message` tool breaks this way, even `approve`, because agent callback values carry the `::` mark and that mark ended up in the action id. The mark first shipped in v2026.11.10-beta.3 and v2026.11.10 (current `latest`). v2026.10.34 (`extended-stable`) and v2026.11.9 and earlier don't have it, so there only non-alphanumeric values break.

Mattermost keeps the action id the post was created with (`server/channels/api4/integration_action.go`, v11.7.15).

## Why This Change Was Made

`buildButtonAttachments` is the one place that turns a button id into the Mattermost action `id` and the signed `context.action_id`.

- An id that is already `[A-Za-z0-9]+` is used unchanged, so the model picker and raw callers produce byte-identical posts.
- Any other id becomes `<its alphanumerics, max 16>x<button index>`. The index after the last `x` makes derived ids unique within a post by construction, including two values that clean to the same text (`yes?` / `yes!`).
- Accepted edge case, not observed: a raw alphanumeric id that equals a derived id in the same post would clash (Mattermost sends the click to the first action with that id). Agent, question and picker ids can't produce it.
- The value itself still travels unchanged in the HMAC-signed `context.callback_data`, which is what the click delivers to the agent. Signing, the post-action match and the click authorization check are unchanged.

The docs no longer say the value is used as the action id, and the 404 troubleshooting entry names the real cause.

## User Impact

Buttons with any value work again, and the agent receives the exact original value. Posts already sent with broken ids stay broken and have to be re-sent. No config or migration is needed.

## Evidence

- Regression test (`interactions.test.ts`): red on main (`expected '::删掉说明和备注两条帖子,只留表' to match /^[A-Za-z0-9]+$/`), green with the fix.
- Live run against Mattermost 11.7.15 with an isolated Gateway built from main and from this head. A scripted model sends a buttons block through the real `message` tool, and user alice clicks through Mattermost's action route, twice per side: #206228 (comment)
- Chromium screenshots: #206228 (comment)

| Case | main | this PR |
| --- | --- | --- |
| Chinese value | 404 "Page not found", no Gateway log, no agent turn | 200, agent gets `删掉说明和备注两条帖子,只留表` |
| Spaces/punctuation `yes, do it! (now)` | 404 | 200, agent gets the exact value |
| Agent value `approve` (`::approve`) | 404 | 200, agent gets `approve` |
| Model picker (`/oc_models`) | 200, id `mdllistb735d7f3f8da` | same id, 200 |
| Tampered `callback_data` or `action_id` | 403 Invalid token | 403 Invalid token |

Merge danger: two-way door. A revert restores the old ids. Nothing is stored and no config changes. Blast radius is Mattermost button posts.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit be5d9a0)
Co-authored-by: RomneyDa <[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 docs Improvements or additions to documentation impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mattermost buttons with non-alphanumeric values (Chinese text, spaces, agent callbacks) open "Page not found" on click

2 participants