Skip to content

Commit

Permalink
Check status codes that profile handler returns
Browse files Browse the repository at this point in the history
fixes matrix-org#8520

Signed-off-by: Pavel Turinsky <pavel.turinsky@matfyz.cz>
  • Loading branch information
Pavel Turinsky committed Oct 17, 2020
1 parent 0afd835 commit 8de99a3
Showing 1 changed file with 8 additions and 0 deletions.
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", str(e.code), e.msg
)
# Change to 500 not to confuse clients
e.code = 500
e.msg = "Remote server replied: {} {}".format(str(e.code), e.msg)
raise e.to_synapse_error()

async def get_profile_from_cache(self, user_id):
Expand Down

0 comments on commit 8de99a3

Please sign in to comment.