fix: handle node absent in 1ml.com (#3180)

This commit is contained in:
Vlad Stan 2025-05-27 17:02:15 +03:00 committed by GitHub
parent 4071925f65
commit e6de66e1b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -212,7 +212,10 @@ async def api_get_1ml_stats(node: Node = Depends(require_node)) -> Optional[Node
r = await client.get(url=f"https://1ml.com/node/{node_id}/json", timeout=15)
try:
r.raise_for_status()
return r.json()["noderank"]
data = r.json()
if "noderank" not in data:
return None
return data["noderank"]
except httpx.HTTPStatusError as exc:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="Node not found on 1ml.com"