fix: improve fetch_remote error handling and diagnostics

- Add _log.warning() to bare except clause in fetch_remote so unexpected
  errors (JSON parse failures, AttributeError, etc.) leave a diagnostic
  trail instead of silently surfacing as 'unreachable'
- Map HTTPStatusError (non-401/403 HTTP errors like 500, 503, 429) to
  'unreachable' instead of 'auth_failed' — semantically correct since
  these are connectivity/server errors, not authentication failures
- Fix stale task comment in test_api.py: task-8 → task-5
This commit is contained in:
Brian Krabach
2026-04-01 14:22:29 -07:00
parent 489a127056
commit b1639826ab
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -946,12 +946,13 @@ async def federation_sessions(request: Request) -> list[dict]:
except httpx.HTTPStatusError: except httpx.HTTPStatusError:
return [ return [
{ {
"status": "auth_failed", "status": "unreachable",
"remoteId": remote_id, "remoteId": remote_id,
"deviceName": remote_name, "deviceName": remote_name,
} }
] ]
except Exception: except Exception as exc:
_log.warning("Unexpected error fetching remote %s: %s", url, exc)
return [ return [
{ {
"status": "unreachable", "status": "unreachable",
+1 -1
View File
@@ -1602,7 +1602,7 @@ def test_federation_client_exists_on_app_state(monkeypatch):
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# GET /api/federation/sessions (task-8) # GET /api/federation/sessions (task-5)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------