diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2021-01-12 11:07:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-12 11:07:01 -0500 |
commit | 723b19748aca0de4ae0eb2d6d89844fad04f29ae (patch) | |
tree | f0f5f02841c0fe593a099b8c8b624f974716efbd | |
parent | Kill off `HomeServer.get_ip_from_request()` (#9080) (diff) | |
download | synapse-723b19748aca0de4ae0eb2d6d89844fad04f29ae.tar.xz |
Handle bad JSON data being returned from the federation API. (#9070)
Diffstat (limited to '')
-rw-r--r-- | changelog.d/9070.bugfix | 1 | ||||
-rw-r--r-- | synapse/http/matrixfederationclient.py | 10 | ||||
-rw-r--r-- | tests/http/test_fedclient.py | 2 |
3 files changed, 12 insertions, 1 deletions
diff --git a/changelog.d/9070.bugfix b/changelog.d/9070.bugfix new file mode 100644 index 0000000000..72b8fe9f1c --- /dev/null +++ b/changelog.d/9070.bugfix @@ -0,0 +1 @@ +Fix `JSONDecodeError` spamming the logs when sending transactions to remote servers. 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", diff --git a/tests/http/test_fedclient.py b/tests/http/test_fedclient.py index 212484a7fe..9c52c8fdca 100644 --- a/tests/http/test_fedclient.py +++ b/tests/http/test_fedclient.py @@ -560,4 +560,4 @@ class FederationClientTests(HomeserverTestCase): self.pump() f = self.failureResultOf(test_d) - self.assertIsInstance(f.value, ValueError) + self.assertIsInstance(f.value, RequestSendFailed) |