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
This commit is contained in:
1 parent
932a4d3022
commit
b438ead6ae
2 files changed
+10
-4
No files matched your search
@@ -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)
|
||||
Reference in new issue
Block a user