Преглед изворни кода

Add GeoNames error response handling in autocomplete endpoint

Lukas Goldschmidt пре 1 месец
родитељ
комит
ca0344deb6
1 измењених фајлова са 4 додато и 0 уклоњено
  1. 4 0
      src/astro_mcp/dashboard.py

+ 4 - 0
src/astro_mcp/dashboard.py

@@ -68,6 +68,10 @@ async def geonames_search(q: str, max_rows: int = 8):
         async with httpx.AsyncClient(timeout=5.0) as client:
             resp = await client.get(url, params=params)
             data = resp.json()
+        # Check for GeoNames error responses
+        if "status" in data and "message" in data["status"]:
+            logger.warning(f"geonames error: {data['status']['message']}")
+            return []
         results = []
         for item in data.get("geonames", []):
             results.append({