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

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

Merged
merged 6 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."
)
DMRobertson marked this conversation as resolved.
Show resolved Hide resolved

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.",
)
DMRobertson marked this conversation as resolved.
Show resolved Hide resolved

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