Skip to content
Snippets Groups Projects
Unverified Commit 723b1974 authored by Patrick Cloke's avatar Patrick Cloke Committed by GitHub
Browse files

Handle bad JSON data being returned from the federation API. (#9070)

parent 0f8945e1
No related branches found
No related tags found
No related merge requests found
Fix `JSONDecodeError` spamming the logs when sending transactions to remote servers.
...@@ -174,6 +174,16 @@ async def _handle_json_response( ...@@ -174,6 +174,16 @@ async def _handle_json_response(
d = timeout_deferred(d, timeout=timeout_sec, reactor=reactor) d = timeout_deferred(d, timeout=timeout_sec, reactor=reactor)
body = await make_deferred_yieldable(d) 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: except defer.TimeoutError as e:
logger.warning( logger.warning(
"{%s} [%s] Timed out reading response - %s %s", "{%s} [%s] Timed out reading response - %s %s",
......
...@@ -560,4 +560,4 @@ class FederationClientTests(HomeserverTestCase): ...@@ -560,4 +560,4 @@ class FederationClientTests(HomeserverTestCase):
self.pump() self.pump()
f = self.failureResultOf(test_d) f = self.failureResultOf(test_d)
self.assertIsInstance(f.value, ValueError) self.assertIsInstance(f.value, RequestSendFailed)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment