From 837fb9ac25560d9a0e1f21cf2a63019e1cf426c9 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Mon, 6 May 2024 12:13:10 -0700 Subject: [PATCH] Update to raise backwards-compat errors for invalid lat/lon --- neon_api_proxy/services/owm_api.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/neon_api_proxy/services/owm_api.py b/neon_api_proxy/services/owm_api.py index 04d2310..f25fa30 100644 --- a/neon_api_proxy/services/owm_api.py +++ b/neon_api_proxy/services/owm_api.py @@ -82,6 +82,11 @@ def handle_query(self, **kwargs) -> dict: def _get_api_response(self, lat: str, lng: str, units: str, api: str = "onecall", lang: str = "en") -> Response: + try: + assert isinstance(float(lat), float), f"Invalid latitude: {lat}" + assert isinstance(float(lng), float), f"Invalid longitude: {lng}" + except AssertionError as e: + raise ValueError(e) if api != "onecall": log_deprecation(f"{api} was requested but only `onecall` " f"is supported", "1.0.0")