Skip to content

Commit 82f8d35

Browse files
author
khushthecoder
committed
Surface ipinfo.io location check failures (closes #1311)
The ipinfo.io lookup in AnophelesBase swallowed every OSError silently, leaving _client_details = None. That cascaded into _get_gcp_region() returning None and the GCS URL optimisation falling back to the default bucket without any indication that the location check had failed. Researchers on restricted networks (corporate firewalls, institutional VPNs, regions where ipinfo.io is blocked) hit this path the most, and had no way to correlate slow downloads with a failed lookup. Now the failure is logged at DEBUG level for users running with debug=True, and a UserWarning is emitted explaining the fallback and pointing to the `url` parameter as a manual override. The fallback behaviour itself is unchanged.
1 parent 9c1bb56 commit 82f8d35

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

malariagen_data/anoph/base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,16 @@ def __init__(
103103
if check_location:
104104
try:
105105
self._client_details = ipinfo.getHandler().getDetails()
106-
except OSError:
107-
pass
106+
except OSError as exc:
107+
self._log.debug(f"Location check failed: {exc}")
108+
warnings.warn(
109+
"Could not determine client location via ipinfo.io "
110+
f"({exc}). Region-optimal GCS bucket selection is "
111+
"unavailable. You can manually specify a region using "
112+
"the `url` parameter.",
113+
UserWarning,
114+
stacklevel=2,
115+
)
108116

109117
# Determine cloud location details.
110118
self._gcp_region = _get_gcp_region(self._client_details)

0 commit comments

Comments
 (0)