mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Handle bad JSON data being returned from the federation API. (#9070)
This commit is contained in:
parent
0f8945e166
commit
723b19748a
1
changelog.d/9070.bugfix
Normal file
1
changelog.d/9070.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fix `JSONDecodeError` spamming the logs when sending transactions to remote servers.
|
@ -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",
|
||||
|
@ -560,4 +560,4 @@ class FederationClientTests(HomeserverTestCase):
|
||||
self.pump()
|
||||
|
||||
f = self.failureResultOf(test_d)
|
||||
self.assertIsInstance(f.value, ValueError)
|
||||
self.assertIsInstance(f.value, RequestSendFailed)
|
||||
|
Loading…
Reference in New Issue
Block a user