Fix Matrix bot autojoin 404 on startup #5

Merged
william merged 2 commits from fix/matrix-autojoin-404 into main 2026-08-23 15:08:37 +00:00
Collaborator

Replaces AutojoinRoomsMixin (whose /joined_rooms scan 404s against Continuwuity) with a lightweight room.invite handler. Fixes the bot silently failing to start after the claude-bot token switch.

Replaces AutojoinRoomsMixin (whose /joined_rooms scan 404s against Continuwuity) with a lightweight room.invite handler. Fixes the bot silently failing to start after the claude-bot token switch.
claude-bot added 2 commits 2026-08-23 15:07:13 +00:00
Same root cause as the earlier whoami fix: the mixin's initial
/joined_rooms scan 404s against Continuwuity even though the endpoint
works fine when called directly. Only auto-join-on-invite was actually
needed, so a plain room.invite listener replaces the whole mixin.
Author
Collaborator

Review summary

Correctness — likely doesn't fix the bug (high confidence, verified against the installed library source):

agent/src/matrixBot.js:47-60 — The PR's premise is that AutojoinRoomsMixin does a /joined_rooms "scan" on startup that 404s against Continuwuity. I checked the installed matrix-bot-sdk@0.7.1 source directly:

  • AutojoinRoomsMixin.setupOnClient(client) (lib/mixins/AutojoinRoomsMixin.js) is literally just client.on("room.invite", (roomId, inviteEvent) => client.joinRoom(roomId)) — no scan, no /joined_rooms call.
  • The actual /joined_rooms call — this.lastJoinedRoomIds = await this.getJoinedRooms() — lives inside MatrixClient.start() itself (lib/MatrixClient.js:559), unconditionally, regardless of whether the mixin is registered. It's followed immediately by await this.getUserId(), which hits /account/whoami — the same endpoint the earlier commit (58bce82) already identified as 404ing on Continuwuity.

Since startMatrixBot() still calls await client.start() (line 99), and doRequest rejects on non-2xx, this call will still throw before the sync loop (and the new room.invite handler) ever runs. The new hand-rolled invite handler is functionally almost identical to what the mixin already did — it just replaces one client.on("room.invite", ...) registration with another, wrapped in try/catch. That doesn't touch the code path that's actually failing.

Recommend verifying against the real Continuwuity error logs which endpoint(s) actually 404 before concluding this is fixed — it may need to skip/replace the getJoinedRooms()/getUserId() calls inside start() itself (similar to how 58bce82 worked around the direct getUserId() call).

Everything else (try/catch around joinRoom, README additions) looks fine and unrelated to the bug.

## Review summary **Correctness — likely doesn't fix the bug (high confidence, verified against the installed library source):** `agent/src/matrixBot.js:47-60` — The PR's premise is that `AutojoinRoomsMixin` does a `/joined_rooms` "scan" on startup that 404s against Continuwuity. I checked the installed `matrix-bot-sdk@0.7.1` source directly: - `AutojoinRoomsMixin.setupOnClient(client)` (`lib/mixins/AutojoinRoomsMixin.js`) is literally just `client.on("room.invite", (roomId, inviteEvent) => client.joinRoom(roomId))` — no scan, no `/joined_rooms` call. - The actual `/joined_rooms` call — `this.lastJoinedRoomIds = await this.getJoinedRooms()` — lives inside `MatrixClient.start()` itself (`lib/MatrixClient.js:559`), unconditionally, regardless of whether the mixin is registered. It's followed immediately by `await this.getUserId()`, which hits `/account/whoami` — the same endpoint the earlier commit (`58bce82`) already identified as 404ing on Continuwuity. Since `startMatrixBot()` still calls `await client.start()` (line 99), and `doRequest` rejects on non-2xx, this call will still throw before the sync loop (and the new `room.invite` handler) ever runs. The new hand-rolled invite handler is functionally almost identical to what the mixin already did — it just replaces one `client.on("room.invite", ...)` registration with another, wrapped in try/catch. That doesn't touch the code path that's actually failing. Recommend verifying against the real Continuwuity error logs which endpoint(s) actually 404 before concluding this is fixed — it may need to skip/replace the `getJoinedRooms()`/`getUserId()` calls inside `start()` itself (similar to how `58bce82` worked around the direct `getUserId()` call). **Everything else** (try/catch around `joinRoom`, README additions) looks fine and unrelated to the bug.
william merged commit 34c2f7d634 into main 2026-08-23 15:08:37 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: william/gitops-automation#5