summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorLEdoian <ghle@pokemon.ledoian.cz>2020-10-26 14:55:21 +0100
committerGitHub <noreply@github.com>2020-10-26 13:55:21 +0000
commit7b13780c54aef09a2ed1fe35325100a652100cb7 (patch)
treed7509626a076b2b7865aeef6cb46dfae0fc1af7b /synapse
parentStart fewer opentracing spans (#8640) (diff)
downloadsynapse-7b13780c54aef09a2ed1fe35325100a652100cb7.tar.xz
Check status codes that profile handler returns (#8580)
Fixes #8520

Signed-off-by: Pavel Turinsky <pavel.turinsky@matfyz.cz>

Co-authored-by: Erik Johnston <erikj@jki.re>
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/profile.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py
index da5692e03e..3875e53c08 100644
--- a/synapse/handlers/profile.py
+++ b/synapse/handlers/profile.py
@@ -98,6 +98,13 @@ class ProfileHandler(BaseHandler):
             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.info(
+                        "Server replied with wrong response: %s %s", e.code, e.msg
+                    )
+
+                    raise SynapseError(502, "Failed to fetch profile")
                 raise e.to_synapse_error()
 
     async def get_profile_from_cache(self, user_id: str) -> JsonDict: