Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 3ad817b

Browse files
authored
Fix federated joins when the first server in the list is not in the room (#15074)
Previously we would give up upon receiving a 404 from the first server, instead of trying the rest of the servers in the list. Signed-off-by: Sean Quah <[email protected]>
1 parent 39795b3 commit 3ad817b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

changelog.d/15074.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a long-standing bug where federated joins would fail if the first server in the list of servers to try is not in the room.

synapse/federation/federation_client.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ async def _try_destination_list(
884884
if 500 <= e.code < 600:
885885
failover = True
886886

887-
elif e.code == 400 and synapse_error.errcode in failover_errcodes:
887+
elif 400 <= e.code < 500 and synapse_error.errcode in failover_errcodes:
888888
failover = True
889889

890890
elif failover_on_unknown_endpoint and self._is_unknown_endpoint(
@@ -999,14 +999,13 @@ async def send_request(destination: str) -> Tuple[str, EventBase, RoomVersion]:
999999

10001000
return destination, ev, room_version
10011001

1002+
failover_errcodes = {Codes.NOT_FOUND}
10021003
# MSC3083 defines additional error codes for room joins. Unfortunately
10031004
# we do not yet know the room version, assume these will only be returned
10041005
# by valid room versions.
1005-
failover_errcodes = (
1006-
(Codes.UNABLE_AUTHORISE_JOIN, Codes.UNABLE_TO_GRANT_JOIN)
1007-
if membership == Membership.JOIN
1008-
else None
1009-
)
1006+
if membership == Membership.JOIN:
1007+
failover_errcodes.add(Codes.UNABLE_AUTHORISE_JOIN)
1008+
failover_errcodes.add(Codes.UNABLE_TO_GRANT_JOIN)
10101009

10111010
return await self._try_destination_list(
10121011
"make_" + membership,

0 commit comments

Comments
 (0)