diff --git a/src/agents/geoparsing.py b/src/agents/geoparsing.py index 18045c2..6dd8d74 100644 --- a/src/agents/geoparsing.py +++ b/src/agents/geoparsing.py @@ -60,7 +60,7 @@ def _geocode_offline(name: str, country_code: str = "") -> Optional[dict]: if matches: # Disambiguierung: country_code bevorzugen, dann Population if country_code: - cc_matches = [c for c in matches if c.get("countrycode", "").upper() == country_code.upper()] + cc_matches = [c for c in matches if c.get("countrycode", "").upper() == (country_code or "").upper()] if cc_matches: matches = cc_matches best = max(matches, key=lambda c: c.get("population", 0)) @@ -95,7 +95,7 @@ def _geocode_location(name: str, country_code: str = "", haiku_coords: Optional[ country_code: ISO-2 Code (von Haiku) haiku_coords: {"lat": float, "lon": float} (Fallback von Haiku) """ - cache_key = f"{name.lower().strip()}|{country_code.upper()}" + cache_key = f"{name.lower().strip()}|{(country_code or '').upper()}" if cache_key in _geocode_cache: return _geocode_cache[cache_key]