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

Commit

Permalink
Make minor clarifications to the error messages given when we fail to…
Browse files Browse the repository at this point in the history
… join a room via any server. (#13160)
  • Loading branch information
reivilibre authored Jul 27, 2022
1 parent 4f3082d commit 39be5bc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/13160.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make minor clarifications to the error messages given when we fail to join a room via any server.
8 changes: 7 additions & 1 deletion synapse/federation/federation_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,12 @@ async def _try_destination_list(
if failover_errcodes is None:
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:
if destination == self.server_name:
continue
Expand Down Expand Up @@ -774,7 +780,7 @@ async def _try_destination_list(
"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(
self,
Expand Down
6 changes: 5 additions & 1 deletion synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,11 @@ async def _remote_join(
]

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
if (
Expand Down
5 changes: 4 additions & 1 deletion tests/rest/admin/test_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,10 @@ def test_room_does_not_exist(self) -> None:
)

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:
"""
Expand Down

0 comments on commit 39be5bc

Please sign in to comment.