From 7a4f9cf29327803597cd39a46df159df4fbabe6c Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 20 Nov 2022 11:37:26 -0700 Subject: Add error catching on actor fetch --- users/models/identity.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'users/models') diff --git a/users/models/identity.py b/users/models/identity.py index 53b6f80..5056ce0 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -297,11 +297,14 @@ class Identity(StatorModel): if self.local: raise ValueError("Cannot fetch local identities") async with httpx.AsyncClient() as client: - response = await client.get( - self.actor_uri, - headers={"Accept": "application/json"}, - follow_redirects=True, - ) + try: + response = await client.get( + self.actor_uri, + headers={"Accept": "application/json"}, + follow_redirects=True, + ) + except (httpx.ReadTimeout, httpx.ReadError): + return False if response.status_code >= 400: return False document = canonicalise(response.json(), include_security=True) -- cgit v1.2.3