From b438ead6ae5509a101f18c19da690d7c1c3afb3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 3 Sep 2026 19:36:25 -0400 Subject: [PATCH] fix: return the degraded deep-health report instead of raising The API answers GET /v1/health/deep with 503 and a full report when a dependency is down. _handle_response raised for every status at or above 400, so deep_health() raised exactly when callers need the dependency details. Both the sync and async clients now accept 503 for this endpoint. Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq --- elydora/async_client.py | 7 +++++-- elydora/client.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/elydora/async_client.py b/elydora/async_client.py index 958f303..3e80523 100644 --- a/elydora/async_client.py +++ b/elydora/async_client.py @@ -130,9 +130,11 @@ class AsyncElydoraClient: headers=build_headers(self.token), ) - async def _get_public(self, path: str) -> Any: + async def _get_public(self, path: str, *, accept_status: Optional[int] = None) -> Any: session = await self._get_session() async with session.get(f"{self.base_url}{path}", timeout=TIMEOUT) as response: + if accept_status is not None and response.status == accept_status: + return await response.json() return await self._handle_response(response) @staticmethod @@ -349,4 +351,5 @@ class AsyncElydoraClient: return await self._get_public("/v1/health") async def deep_health(self) -> DeepHealthResponse: - return await self._get_public("/v1/health/deep") + """503 carries the degraded report, not an error.""" + return await self._get_public("/v1/health/deep", accept_status=503) diff --git a/elydora/client.py b/elydora/client.py index d8f8f2e..53a69d0 100644 --- a/elydora/client.py +++ b/elydora/client.py @@ -119,8 +119,10 @@ class ElydoraClient: headers=build_headers(self.token), ) - def _get_public(self, path: str) -> Any: + def _get_public(self, path: str, *, accept_status: Optional[int] = None) -> Any: response = self._session.get(f"{self.base_url}{path}", timeout=REQUEST_TIMEOUT_SECONDS) + if accept_status is not None and response.status_code == accept_status: + return response.json() return self._handle_response(response) @staticmethod @@ -324,4 +326,5 @@ class ElydoraClient: return self._get_public("/v1/health") def deep_health(self) -> DeepHealthResponse: - return self._get_public("/v1/health/deep") + """503 carries the degraded report, not an error.""" + return self._get_public("/v1/health/deep", accept_status=503)