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

Check status codes that profile handler returns #8580

Merged
merged 5 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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/8580.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug where Synapse would blindly forward bad responses from federation to clients when retrieving profile information.
8 changes: 8 additions & 0 deletions synapse/handlers/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ async def get_profile(self, user_id):
except RequestSendFailed as e:
raise SynapseError(502, "Failed to fetch profile") from e
except HttpResponseException as e:
if e.code < 500 and e.code != 404:
# Other codes are not allowed in c2s API
logger.error(
"Server replied with wrong response: %s %s", e.code, e.msg
)
# Change to 500 not to confuse clients
e.code = 500
e.msg = "Remote server replied: {} {}".format(e.code, e.msg)
LEdoian marked this conversation as resolved.
Show resolved Hide resolved
raise e.to_synapse_error()

async def get_profile_from_cache(self, user_id):
Expand Down