Repository navigation
fix(matrix): reject unmatchable autoJoinAllowlist entries - #161607
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 30, 2026, 2:42 AM ET / 06:42 UTC (Revision 3). ClawSweeper reviewWhat this changesThe Matrix plugin now warns when an invite auto-join allowlist contains entries that cannot identify a room, shares the target check with setup, and updates tests and guidance. Merge readiness✅ Ready for maintainer review The PR addresses the silent Matrix configuration failure without invalidating saved settings. Current main and the latest release still lack this warning. The prior alias-shape finding is fixed, and this review found no new blocking patch defect. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway loads Matrix account settings and passes them to the Matrix plugin. The plugin checks room invites against the configured allowlist, then either joins the room or leaves the invite unanswered. flowchart LR
A[Saved Matrix settings] --> B[Matrix account configuration]
B --> C[Invite target check]
C --> D[Configuration warning]
C --> E[Room invite handler]
E --> F[Join allowed room]
E --> G[Ignore unmatched invite]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +29, Tests +84, Docs 0. Total +113 across 7 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. Technical reviewBest possible solution: Keep saved Matrix configurations loadable while giving operators a clear warning and documented choice of room-scoped auto-join or Do we have a high-confidence way to reproduce the issue? Yes. Current-main source shows that user IDs cannot satisfy the invite check, and the contributor supplies a saved-config before/after trace for the warning; this reviewer did not execute contributor code. Is this the best way to solve the issue? Yes for the silent-failure problem: a warning gives a useful result while preserving accepted saved settings. Sender-based auto-join would be a separate policy change. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3801005f6951. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
cfab9b2 to
bb271cd
Compare
|
@clawsweeper re-review Rewrote the fix to the recommended warn-without-blocking route and added Gateway-path proof:
|
|
🦞👀 Re-review progress:
|
channels.matrix.autoJoinAllowlist accepts Matrix user IDs, but the invite handler only matches a room ID, an alias, or "*": a user ID validated cleanly, was persisted, and then silently ignored every invite with no output at the default log level. Clients also mint a fresh room ID per DM, so a room-ID allowlist cannot cover DMs either. Keep the field schema unchanged so saved configurations still load, and warn once at registration naming entries the room matcher can never use. The check reuses the setup wizard's invite-target predicate, moved to the shared target-ids owner so setup and runtime cannot drift.
bb271cd to
bdac481
Compare
|
@clawsweeper re-review Addressed the remaining review items:
Re-verified on the new base: Gateway-path BEFORE exit 1 / AFTER exit 0 (saved config still loads, warning now emitted), target suites 47/47, and |
|
🦞👀 Re-review progress:
|
|
Verified the existing head
No source changes or push were needed. Main's changes to the touched files are non-overlapping, The exact-head CI gate is successful and ClawSweeper is ready on this SHA. The four cancelled entries are orchestration, not selected test shards: Auto response, two ClawSweeper Dispatch jobs, and PR context and evidence. Auto response and PR context have successful exact-head runs; ClawSweeper subsequently completed the exact-head ready review. There are no cancelled selected test file lists to replay and no failing jobs. |
|
Landed. Thanks @xydigitLybnnnn! Verified against a private Synapse: on main an invite from an allowlisted user ID was silently ignored; with this the operator gets a default-level warning naming the entry, room-ID/alias/* entries still auto-join, and an existing config with a user-ID entry still loads without a migration. |
…aw#161607) Matrix invites are matched against room IDs, aliases and *, never the inviting user. A user-ID entry in channels.matrix.autoJoinAllowlist now logs a default-level warning naming it instead of silently ignoring every invite, and onboarding and docs no longer suggest user IDs. Existing configs still load unchanged. Fixes openclaw#160951. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Issue #160951 —
channels.matrix.autoJoinAllowlistaccepts and validates Matrix user IDs (@user:server), but the invite handler never compares against the inviting user. It only matches room IDs (!…), aliases (#…), or*. A user-ID entry validates cleanly, is persisted, and then silently ignores every invite; the only trace waslogVerbose(off by default).Two things make this the worst pairing for operators:
autoJoinAllowlistsits besidedm.allowFrom, which is a user-ID list, so a user ID reads as the natural value.Root cause
extensions/matrix/src/matrix/monitor/auto-join.ts—onInvite(roomId, _inviteEvent)never inspects the inviter, and the allowlist test is:allowedRoomIdscollects!-prefixed entries andallowedAliasescollects#-prefixed entries, so any@-prefixed entry falls through every branch. The only signal for an ignored invite waslogVerbose, which is silent at the default log level.The fix
Warn without blocking (the recommended route from review). This change does not tighten
channels.matrix.autoJoinAllowlist, so a saved user-ID entry keeps loading and an existing installation is not broken on update. Instead:extensions/matrix/src/matrix/target-ids.ts— the shared Matrix target contract now exposesisMatrixInviteAutoJoinTarget(): the wildcard, a literal room ID, or a full#alias:serverwith a non-empty local part and server name (so#ops:,#:example.org, and#missing-serverare all inert). This is the same predicate the setup wizard already enforced for the field, promoted to the target-ids owner so config, setup, and runtime cannot drift.extensions/matrix/src/onboarding.ts— imports the shared predicate and drops its private copy; the wizard keeps re-prompting on invalid entries, now from the single owner.extensions/matrix/src/matrix/monitor/auto-join.ts— whenautoJoin: "allowlist"holds entries that can never match an invited room, the handler emits one warning naming them through the plugin logger (default level). It fires once at registration, not per invite, so it cannot spam. This also covers account-scoped config (channels.matrix.accounts.<id>), which is schema-open and has no separate validation.Docs (
docs/channels/matrix/setup.md,docs/channels/matrix.md) now state that non-room entries cannot match and are warned about, and that sender authorization belongs indm.allowFrom.Evidence
1. Gateway path, BEFORE (exit 1) → AFTER (exit 0)
Harness:
harness/gateway-autojoin-repro.mts, run withnode --import ./scripts/tsx.mjs. It writes a real saved config file, loads it through the real Gateway config loader (loadConfigfromsrc/config/io.runtime.ts), resolves the Matrix account config with the realresolveMatrixAccountConfig, and drives the realregisterMatrixAutoJoinhandler with a Matrix client boundary stub emitting a realroom.inviteevent.This proves the saved user-ID entry still loads (no
INVALID_CONFIG, no migration needed) and that the inert entry is now reported.The config result is identical in both runs (
loadConfig: OK) — the saved configuration remains loadable, so there is no upgrade breakage. The only delta is the new default-level diagnostic.Transcripts:
harness/gateway-before-fix.txt,harness/gateway-after-fix.txt; combined transcript interminal-output.txt.2. Target suites
Measured cost (local, Linux x64): the three changed Matrix test files run as one Vitest shard in 105 s wall (worker/transform ~88%, tests ~1%); the added table cases are negligible. Only
auto-join.test.tsandtarget-ids.test.tsare changed test files.3. Project gates
Full log:
check-changed.log. TheOPENCLAW_PLUGIN_SDK_BOUNDARY_ROOT_SHIMS_TIMEOUT_MSoverride only raises this local host's 300 s default for theplugin-sdkboundary-dts pre-step (it exceeded 300 s on this slow box after the dependency bump); it does not change repository behavior or any check's assertions.Risk checklist
autoJoinAllowlistis untouched, so saved configs (including user-ID entries) keep loading. No Doctor migration is required and no upgrade path changes.!room,#alias:server,*, and absent allowlists keep the exact previous behavior; the alias-resolution and retry paths are unchanged.!,#missing-server,#ops:,#:example.org) are now reported instead of silently ignored; they never matched a room before either.autoJoin: "allowlist";offandalwaysnever reach it.dm.allowFrom/groupAllowFrombehavior changes. Joining a room is not acting in it; sender authorization stays withdm.allowFrom.Declared gaps
MatrixClientis a boundary stub. Config loading uses the real Gateway loader and the invite path runs the real handler.Rebased onto current
mainto resolve the merge conflict.Fixes #160951.
Maintainer verification
Private Synapse and built-Gateway before/after, saved-config compatibility, room/alias/wildcard controls, and focused regression results: #161607 (comment)
No overlap with Pash/Sarah changes.