kopia lustrzana https://github.com/jointakahe/takahe
Correctly handle response.raise_for_status() and guard search from bubbling parse errors (#322)
rodzic
0250f2800b
commit
75c17c0766
|
@ -41,15 +41,18 @@ class SearchService:
|
||||||
username__iexact=username,
|
username__iexact=username,
|
||||||
)
|
)
|
||||||
except Identity.DoesNotExist:
|
except Identity.DoesNotExist:
|
||||||
|
identity = None
|
||||||
if self.identity is not None:
|
if self.identity is not None:
|
||||||
|
try:
|
||||||
# Allow authenticated users to fetch remote
|
# Allow authenticated users to fetch remote
|
||||||
identity = Identity.by_username_and_domain(
|
identity = Identity.by_username_and_domain(
|
||||||
username, domain_instance or domain, fetch=True
|
username, domain_instance or domain, fetch=True
|
||||||
)
|
)
|
||||||
if identity and identity.state == IdentityStates.outdated:
|
if identity and identity.state == IdentityStates.outdated:
|
||||||
async_to_sync(identity.fetch_actor)()
|
async_to_sync(identity.fetch_actor)()
|
||||||
else:
|
except ValueError:
|
||||||
identity = None
|
pass
|
||||||
|
|
||||||
if identity:
|
if identity:
|
||||||
results.add(identity)
|
results.add(identity)
|
||||||
|
|
||||||
|
|
|
@ -640,7 +640,7 @@ class Identity(StatorModel):
|
||||||
headers={"Accept": "application/json"},
|
headers={"Accept": "application/json"},
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except httpx.RequestError as ex:
|
except httpx.HTTPError as ex:
|
||||||
response = getattr(ex, "response", None)
|
response = getattr(ex, "response", None)
|
||||||
if (
|
if (
|
||||||
response
|
response
|
||||||
|
|
Ładowanie…
Reference in New Issue