From 5de3a7ad67f1a34fc140e8b6d24777932c0f5917 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 20 Nov 2022 18:45:28 -0700 Subject: Raise proper errors when it's our fault --- users/models/identity.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'users/models') 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") -- cgit v1.2.3