diff --git a/app/main.py b/app/main.py index 592b348..e7ddff1 100644 --- a/app/main.py +++ b/app/main.py @@ -73,7 +73,14 @@ async def portal_get(path: str) -> dict: async with httpx.AsyncClient(timeout=20.0) as client: r = await client.get(f"{PORTAL_BASE}{path}", headers={"X-Admin-Token": ADMIN_TOKEN}) if r.status_code != 200: - raise HTTPException(502, f"Portal error {r.status_code}") + # Same rule as portal_post: the portal's own status and words, never a + # blanket 502. A rate limit or a refusal is not a gateway failure, and + # reporting one as the other tells the operator nothing they can act on. + try: + detail = r.json().get("detail", r.text) + except Exception: + detail = r.text + raise HTTPException(r.status_code, f"Portal error {r.status_code}: {detail}") return r.json()