瀏覽代碼

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({