Repository navigation
fix(matrix): reject invalid tokens when userId is configured - #123766
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 1:48 PM ET / 17:48 UTC. ClawSweeper reviewWhat this changesThe PR makes Matrix credential probes authenticate the token even when a configured Matrix user ID is present, then rejects a token that authenticates as a different user. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open. This maintainer-owned PR fixes a real Matrix false-green probe path and has no blocking patch finding; land after exact-head required checks are green. Likely related people: @steipete (high confidence; introduced the current probe path and recent Matrix SDK work). Priority: P2 Review scores
Verification
How this fits togetherThe Matrix plugin’s channel-status probe creates a temporary Matrix client from configured account credentials and reports whether that account can authenticate. Its result feeds the shared channel-status command so operators can distinguish healthy credentials from invalid or mismatched ones. flowchart LR
A[Configured Matrix account] --> B[Channel status probe]
B --> C[Temporary Matrix client]
C --> D[Authenticated identity check]
D --> E[Probe result]
E --> F[Operator status output]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +4, Tests +18. Total +22 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep authenticated identity validation in the Matrix plugin and merge after green exact-head checks. Do we have a high-confidence way to reproduce the issue? Yes—current source shows a configured user ID short-circuits authenticated whoami resolution, and the PR body supplies a controlled after-fix Matrix HTTP scenario. Is this the best way to solve the issue? Yes—the Matrix plugin owns client construction and probe identity validation; changing shared status policy or configuration would be broader and less maintainable. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against eab9cf5ea484. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
3ae55df to
36b400f
Compare
|
Merged via squash.
|
Closes #123763
What Problem This Solves
Fixes an issue where
openclaw channels status --probecould report a Matrix account as working with an invalid access token whenever that account also configureduserId. The probe trusted the local configured identity instead of authenticating the token.Why This Change Was Made
The Matrix probe now creates its non-persistent client without seeding the configured
userId, so the existing wrappergetUserId()path authenticates through/account/whoami. It then rejects a valid token whose authenticated identity differs from the configured user.This keeps the repair inside the Matrix plugin owner. It does not change core channel-status policy, configuration, the public Plugin SDK, auth storage, migrations, dependencies, or the changelog.
Dependency contract: in
[email protected],getUserId()returns the configured credential identity, whilewhoami()performs authenticated I/O. OpenClaw's wrapper calls whoami only when no local user ID is seeded.User Impact
Matrix operators can trust an explicit channel probe: invalid tokens now fail with the Matrix status/error, valid matching tokens pass, and tokens for a different configured Matrix user fail with an actionable identity-mismatch error.
Evidence
Exact reviewed head:
36b400f851cdf2631184023e9a585313f61f25e4Before the fix, the focused regression failed 1/7 because the authenticated identity path was never reached when
userIdwas configured.After the fix:
node scripts/run-vitest.mjs extensions/matrix/src/matrix/probe.test.ts— 7/7 passed.node scripts/run-vitest.mjs extensions/matrix/src/channel.account-paths.test.ts— 2/2 passed.node scripts/run-vitest.mjs src/gateway/server-methods/channels.status.test.ts— 15/15 passed.oxfmt --checkandgit diff --checkpassed.node scripts/check-changed.mjs -- extensions/matrix/src/matrix/probe.ts extensions/matrix/src/matrix/probe.test.tspassed all selected extension/test typecheck, lint, dependency, plugin-boundary, database/media/runtime, and import-cycle gates. The remoteci-fastprovider was unavailable, so the repository wrapper used its documented local fallback.patch is correct(0.99).The final head was mechanically rebased onto repaired main
36c440aa2b1e5bb6821945956295f7b01a553f06after current-main CI fixes landed. All focused proof, the changed gate, and autoreview were rerun on the final head. The changed gate passed with the environment ratchet restored to 502/502.Controlled local Matrix HTTP proof used synthetic credentials and made no sends:
{ "invalid": { "ok": false, "status": 401, "error": "Invalid access token" }, "matching": { "ok": true, "userId": "@bot:example.org" }, "mismatched": { "ok": false, "error": "Matrix access token user does not match configured userId" }, "jsonProbeOk": false, "humanProbeFailed": true, "requestCount": 3, "onlyWhoamiGets": true, "sends": 0 }Production LOC: +7/-3 (net +4). The four added lines enforce the authenticated-identity boundary and configured/token identity match without adding a second probe path. Tests: +25/-7.
ClawSweeper Review
The merge-risk move is resolved by explicit maintainer decision: production net +4 is approved because the authenticated-versus-configured identity comparison is the required owner-boundary invariant. ClawSweeper also concluded that no safe net-neutral refactor is evident, identified no actionable finding or security concern, and judged this the best fix location. The optional exact-head-check move remains the landing gate and will be completed before merge.
AI-assisted: yes. The operator approved the invariant and landing; the implementation, dependency source, tests, controlled behavior proof, and final diff were independently reviewed.