Make minor clarifications to the error messages given when we fail to join a room via any server. (#13160)

1.103.0-whithout-watcha
reivilibre 2 years ago committed by GitHub
parent 4f3082d6bf
commit 39be5bc550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      changelog.d/13160.misc
  2. 8
      synapse/federation/federation_client.py
  3. 6
      synapse/handlers/room_member.py
  4. 5
      tests/rest/admin/test_room.py

@ -0,0 +1 @@
Make minor clarifications to the error messages given when we fail to join a room via any server.

@ -725,6 +725,12 @@ class FederationClient(FederationBase):
if failover_errcodes is None: if failover_errcodes is None:
failover_errcodes = () failover_errcodes = ()
if not destinations:
# Give a bit of a clearer message if no servers were specified at all.
raise SynapseError(
502, f"Failed to {description} via any server: No servers specified."
)
for destination in destinations: for destination in destinations:
if destination == self.server_name: if destination == self.server_name:
continue continue
@ -774,7 +780,7 @@ class FederationClient(FederationBase):
"Failed to %s via %s", description, destination, exc_info=True "Failed to %s via %s", description, destination, exc_info=True
) )
raise SynapseError(502, "Failed to %s via any server" % (description,)) raise SynapseError(502, f"Failed to {description} via any server")
async def make_membership_event( async def make_membership_event(
self, self,

@ -1679,7 +1679,11 @@ class RoomMemberMasterHandler(RoomMemberHandler):
] ]
if len(remote_room_hosts) == 0: if len(remote_room_hosts) == 0:
raise SynapseError(404, "No known servers") raise SynapseError(
404,
"Can't join remote room because no servers "
"that are in the room have been provided.",
)
check_complexity = self.hs.config.server.limit_remote_rooms.enabled check_complexity = self.hs.config.server.limit_remote_rooms.enabled
if ( if (

@ -1873,7 +1873,10 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
) )
self.assertEqual(HTTPStatus.NOT_FOUND, channel.code, msg=channel.json_body) self.assertEqual(HTTPStatus.NOT_FOUND, channel.code, msg=channel.json_body)
self.assertEqual("No known servers", channel.json_body["error"]) self.assertEqual(
"Can't join remote room because no servers that are in the room have been provided.",
channel.json_body["error"],
)
def test_room_is_not_valid(self) -> None: def test_room_is_not_valid(self) -> None:
""" """

Loading…
Cancel
Save