From b1639826abd6fdb74206a989a1e57fe6f5e63e7c Mon Sep 17 00:00:00 2001 From: Brian Krabach Date: Wed, 1 Apr 2026 14:22:29 -0700 Subject: [PATCH] fix: improve fetch_remote error handling and diagnostics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- muxplex/main.py | 5 +++-- muxplex/tests/test_api.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/muxplex/main.py b/muxplex/main.py index c65932f..144f88c 100644 --- a/muxplex/main.py +++ b/muxplex/main.py @@ -946,12 +946,13 @@ async def federation_sessions(request: Request) -> list[dict]: except httpx.HTTPStatusError: return [ { - "status": "auth_failed", + "status": "unreachable", "remoteId": remote_id, "deviceName": remote_name, } ] - except Exception: + except Exception as exc: + _log.warning("Unexpected error fetching remote %s: %s", url, exc) return [ { "status": "unreachable", diff --git a/muxplex/tests/test_api.py b/muxplex/tests/test_api.py index 06ef64f..9e54164 100644 --- a/muxplex/tests/test_api.py +++ b/muxplex/tests/test_api.py @@ -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) # ---------------------------------------------------------------------------