fix(matrix): decline dead/abandoned invites instead of retrying forever (#56222)

An invite to a room with no remaining members surfaces as "no servers
in the room have been provided" or "room not found" on join. The pending
invite was never cleared, so every gateway startup re-attempted the join
and re-emitted the warning indefinitely.

Detect that specific failure mode by narrow error-message match and call
leave_room to decline the invite; transient/network errors leave the
invite untouched for the next sync. Adds 5 tests.

Reimplements the matrix portion of #33953 onto the current plugin adapter
(gateway/platforms/matrix.py was relocated to
plugins/platforms/matrix/adapter.py since the PR was opened). The two
gateway/status.py fixes from that PR (wrapper-subcommand rejection,
psutil start-time fallback) already landed on main independently.

Reported by @Bougey; original patch authored by @KiraKatana.
This commit is contained in:
Teknium 2026-07-01 02:44:18 -07:00 committed by GitHub
parent 88d6e833f1
commit 275e293f54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 97 additions and 0 deletions

View file

@ -2947,6 +2947,19 @@ class MatrixAdapter(BasePlatformAdapter):
return True
except Exception as exc:
logger.warning("Matrix: error joining %s: %s", room_id, exc)
# Abandoned rooms (no current members) surface as "no servers
# in the room have been provided" or "room not found". The
# pending invite keeps retrying every startup unless we
# explicitly leave it. The match is narrow enough that
# transient failures still leave the invite untouched for the
# next try.
msg = str(exc).lower()
if ("no servers" in msg) or ("room not found" in msg):
try:
await self._client.leave_room(RoomID(room_id))
logger.info("Matrix: declined dead invite to %s", room_id)
except Exception:
pass
return False
def _schedule_invite_join(