summary refs log tree commit diff
diff options
context:
space:
mode:
authorSean Quah <8349537+squahtx@users.noreply.github.com>2023-02-15 13:59:06 +0000
committerGitHub <noreply@github.com>2023-02-15 13:59:06 +0000
commit3ad817bfe561e0b7ddcd8398a76a4a4d3d789138 (patch)
tree671b7b7881ef3241b6beca935d1052c4f3a71961
parentMake it easier to use DataGrip w/ Synapse's schema (#14982) (diff)
downloadsynapse-3ad817bfe561e0b7ddcd8398a76a4a4d3d789138.tar.xz
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 <seanq@matrix.org>
-rw-r--r--changelog.d/15074.bugfix1
-rw-r--r--synapse/federation/federation_client.py11
2 files changed, 6 insertions, 6 deletions
diff --git a/changelog.d/15074.bugfix b/changelog.d/15074.bugfix
new file mode 100644
index 0000000000..d1ceb4f4c8
--- /dev/null
+++ b/changelog.d/15074.bugfix
@@ -0,0 +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.
diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py
index 0ac85a3be7..7d04560dca 100644
--- a/synapse/federation/federation_client.py
+++ b/synapse/federation/federation_client.py
@@ -884,7 +884,7 @@ class FederationClient(FederationBase):
                 if 500 <= e.code < 600:
                     failover = True
 
-                elif e.code == 400 and synapse_error.errcode in failover_errcodes:
+                elif 400 <= e.code < 500 and synapse_error.errcode in failover_errcodes:
                     failover = True
 
                 elif failover_on_unknown_endpoint and self._is_unknown_endpoint(
@@ -999,14 +999,13 @@ class FederationClient(FederationBase):
 
             return destination, ev, room_version
 
+        failover_errcodes = {Codes.NOT_FOUND}
         # MSC3083 defines additional error codes for room joins. Unfortunately
         # we do not yet know the room version, assume these will only be returned
         # by valid room versions.
-        failover_errcodes = (
-            (Codes.UNABLE_AUTHORISE_JOIN, Codes.UNABLE_TO_GRANT_JOIN)
-            if membership == Membership.JOIN
-            else None
-        )
+        if membership == Membership.JOIN:
+            failover_errcodes.add(Codes.UNABLE_AUTHORISE_JOIN)
+            failover_errcodes.add(Codes.UNABLE_TO_GRANT_JOIN)
 
         return await self._try_destination_list(
             "make_" + membership,