fix: [30388f42] Mache den Worker robust gegenüber gelöschten Entitäten
- Fügt eine zum hinzu, die bei einem HTTP 404 Fehler ausgelöst wird. - Fängt diese im ab. - Markiert Jobs, die sich auf nicht (mehr) existierende Kontakte oder Personen beziehen, als anstatt . - Dies verhindert, dass die Fehlerwarteschlange mit Jobs für gelöschte Entitäten überläuft, was das Hauptproblem der "failed"-Jobs löst.
This commit is contained in:
@@ -8,6 +8,10 @@ import logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger("superoffice-client")
|
||||
|
||||
class ContactNotFoundException(Exception):
|
||||
"""Custom exception for 404 errors on Contact/Person lookups."""
|
||||
pass
|
||||
|
||||
class SuperOfficeClient:
|
||||
"""A client for interacting with the SuperOffice REST API."""
|
||||
|
||||
@@ -117,6 +121,11 @@ class SuperOfficeClient:
|
||||
return resp.json()
|
||||
|
||||
except requests.exceptions.HTTPError as e:
|
||||
# Explicitly handle 404 Not Found for GET requests
|
||||
if method == "GET" and e.response.status_code == 404:
|
||||
logger.warning(f"🔍 404 Not Found for GET request to {endpoint}.")
|
||||
raise ContactNotFoundException(f"Entity not found at {endpoint}") from e
|
||||
|
||||
logger.error(f"❌ API {method} Error for {endpoint} (Status: {e.response.status_code}): {e.response.text}")
|
||||
return None
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user