From d4401651b6279cf674a23da7b4289b3c45606389 Mon Sep 17 00:00:00 2001 From: Inferencebot Date: Fri, 13 Nov 2026 22:47:39 +0000 Subject: [PATCH] portal_get kept the blanket 502 too Fixing portal_post only closed half of it: portal_get still turned any non-200 from the portal into a 502, so a refusal or a rate limit on a read path would have arrived as a gateway error as well. Both helpers now pass the portal's own status and detail through. --- app/main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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()