Correctly handle response.raise_for_status() and guard search from bubbling parse errors (#322)

This commit is contained in:
Michael Manfre 2022-12-30 03:02:33 -05:00 committed by GitHub
parent 0250f2800b
commit 75c17c0766
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View file

@ -41,15 +41,18 @@ class SearchService:
username__iexact=username,
)
except Identity.DoesNotExist:
identity = None
if self.identity is not None:
# Allow authenticated users to fetch remote
identity = Identity.by_username_and_domain(
username, domain_instance or domain, fetch=True
)
if identity and identity.state == IdentityStates.outdated:
async_to_sync(identity.fetch_actor)()
else:
identity = None
try:
# Allow authenticated users to fetch remote
identity = Identity.by_username_and_domain(
username, domain_instance or domain, fetch=True
)
if identity and identity.state == IdentityStates.outdated:
async_to_sync(identity.fetch_actor)()
except ValueError:
pass
if identity:
results.add(identity)

View file

@ -640,7 +640,7 @@ class Identity(StatorModel):
headers={"Accept": "application/json"},
)
response.raise_for_status()
except httpx.RequestError as ex:
except httpx.HTTPError as ex:
response = getattr(ex, "response", None)
if (
response