diff --git a/lib/galaxy/agents/iwc.py b/lib/galaxy/agents/iwc.py index 14a1c6e7b12..cc5386aa77f 100644 --- a/lib/galaxy/agents/iwc.py +++ b/lib/galaxy/agents/iwc.py @@ -33,6 +33,16 @@ def clear_manifest_cache() -> None: _manifest_cache.clear() +def _download_manifest(timeout: float) -> list[dict[str, Any]]: + """Fetch and validate the IWC manifest over the network, bypassing the cache.""" + response = requests.get(IWC_MANIFEST_URL, timeout=timeout) + response.raise_for_status() + manifest = response.json() + if not isinstance(manifest, list): + raise ValueError(f"IWC manifest at {IWC_MANIFEST_URL} did not return a JSON array") + return manifest + + def fetch_manifest(timeout: float = 30.0) -> list[dict[str, Any]]: """Fetch the IWC manifest, returning a cached copy when fresh. @@ -44,11 +54,7 @@ def fetch_manifest(timeout: float = 30.0) -> list[dict[str, Any]]: if cached is not None: return cached - response = requests.get(IWC_MANIFEST_URL, timeout=timeout) - response.raise_for_status() - manifest = response.json() - if not isinstance(manifest, list): - raise ValueError(f"IWC manifest at {IWC_MANIFEST_URL} did not return a JSON array") + manifest = _download_manifest(timeout) _manifest_cache[_CACHE_KEY] = manifest return manifest @@ -66,11 +72,7 @@ def refresh_manifest(timeout: float = 30.0) -> list[dict[str, Any]]: continue without the data); this one is called from a periodic task that has to tolerate transient failure. """ - response = requests.get(IWC_MANIFEST_URL, timeout=timeout) - response.raise_for_status() - manifest = response.json() - if not isinstance(manifest, list): - raise ValueError(f"IWC manifest at {IWC_MANIFEST_URL} did not return a JSON array") + manifest = _download_manifest(timeout) with _manifest_cache_lock: _manifest_cache[_CACHE_KEY] = manifest return manifest