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.
This commit is contained in:
1 parent
1239da192b
commit
d4401651b6
1 file changed
+8
-1
+8
-1
@@ -73,7 +73,14 @@ async def portal_get(path: str) -> dict:
|
|||||||
async with httpx.AsyncClient(timeout=20.0) as client:
|
async with httpx.AsyncClient(timeout=20.0) as client:
|
||||||
r = await client.get(f"{PORTAL_BASE}{path}", headers={"X-Admin-Token": ADMIN_TOKEN})
|
r = await client.get(f"{PORTAL_BASE}{path}", headers={"X-Admin-Token": ADMIN_TOKEN})
|
||||||
if r.status_code != 200:
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user