diff options
author | Andrew Godwin | 2022-11-20 18:45:28 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-11-20 18:45:28 -0700 |
commit | 5de3a7ad67f1a34fc140e8b6d24777932c0f5917 (patch) | |
tree | d67f80662d53e64176c35ad74af4e70652a0e185 /users/models | |
parent | 6a8fe5cb4b4cf9bbe9fe6706620ea93bf46ea3ee (diff) | |
download | takahe-5de3a7ad67f1a34fc140e8b6d24777932c0f5917.tar.gz takahe-5de3a7ad67f1a34fc140e8b6d24777932c0f5917.tar.bz2 takahe-5de3a7ad67f1a34fc140e8b6d24777932c0f5917.zip |
Raise proper errors when it's our fault
Diffstat (limited to 'users/models')
-rw-r--r-- | users/models/identity.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/users/models/identity.py b/users/models/identity.py index c2edf92..dc2ee26 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -307,11 +307,15 @@ class Identity(StatorModel): ) except httpx.RequestError: return None, None - if response.status_code == 404: - # We don't trust this as much as 410 Gone, but skip for now + if response.status_code in [404, 410]: return None, None if response.status_code >= 500: return None, None + if response.status_code >= 400: + raise ValueError( + f"Client error fetching webfinger: {response.status_code}", + response.content, + ) data = response.json() if data["subject"].startswith("acct:"): data["subject"] = data["subject"][5:] @@ -347,6 +351,10 @@ class Identity(StatorModel): return False if response.status_code >= 500: return False + if response.status_code >= 400: + raise ValueError( + f"Client error fetching actor: {response.status_code}", response.content + ) document = canonicalise(response.json(), include_security=True) self.name = document.get("name") self.profile_uri = document.get("url") |