summary refs log tree commit diff
path: root/synapse/http
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2021-01-12 11:07:01 -0500
committerGitHub <noreply@github.com>2021-01-12 11:07:01 -0500
commit723b19748aca0de4ae0eb2d6d89844fad04f29ae (patch)
treef0f5f02841c0fe593a099b8c8b624f974716efbd /synapse/http
parentKill off `HomeServer.get_ip_from_request()` (#9080) (diff)
downloadsynapse-723b19748aca0de4ae0eb2d6d89844fad04f29ae.tar.xz
Handle bad JSON data being returned from the federation API. (#9070)
Diffstat (limited to 'synapse/http')
-rw-r--r--synapse/http/matrixfederationclient.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py
index b261e078c4..b7103d6541 100644
--- a/synapse/http/matrixfederationclient.py
+++ b/synapse/http/matrixfederationclient.py
@@ -174,6 +174,16 @@ async def _handle_json_response(
         d = timeout_deferred(d, timeout=timeout_sec, reactor=reactor)
 
         body = await make_deferred_yieldable(d)
+    except ValueError as e:
+        # The JSON content was invalid.
+        logger.warning(
+            "{%s} [%s] Failed to parse JSON response - %s %s",
+            request.txn_id,
+            request.destination,
+            request.method,
+            request.uri.decode("ascii"),
+        )
+        raise RequestSendFailed(e, can_retry=False) from e
     except defer.TimeoutError as e:
         logger.warning(
             "{%s} [%s] Timed out reading response - %s %s",