OpenBB-finance/OpenBB · error · OpenBBError
Failed to fetch data: {response.status} -> {response.reason}
Error message
Failed to fetch data: {response.status} -> {response.reason} What it means
Raised by the IMF port_info fetcher when the initial request to the PortWatch ports database ArcGIS FeatureServer (all-ports query) returns a non-200 status. Includes both the status code and reason phrase to aid diagnosis. Any subsequent exception in the fetch is re-wrapped by the outer handler as OpenBBError.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/models/port_info.py:244
credentials: dict[str, str] | None,
**kwargs: Any,
) -> list:
"""Extract the raw data from the IMF Port Watch API."""
# pylint: disable=import-outside-toplevel
from openbb_core.provider.utils.helpers import get_async_requests_session
all_ports_url = (
"https://services9.arcgis.com/weJ1QsnbMYJlCHdG/arcgis/rest/services/PortWatch_ports_database/FeatureServer/0/query?"
+ "where=1%3D1&outFields=*&returnGeometry=false&outSR=&f=json"
)
try:
output: list = []
data: dict = {}
async with await get_async_requests_session() as session:
async with await session.get(all_ports_url) as response:
if response.status != 200:
raise OpenBBError(
f"Failed to fetch data: {response.status} -> {response.reason}"
)
data = await response.json()
if "features" in data:
output.extend(data["features"])
if "exceededTransferLimit" in data:
while data.get("exceededTransferLimit"):
offset = len(output)
url = f"{all_ports_url}&resultOffset={offset}"
async with await session.get(url) as response:
if response.status != 200:
raise OpenBBError(
f"Failed to fetch data: {response.status}"
)View on GitHub (pinned to 3e071fcc2c)
Solutions
- Retry after a delay; transient ArcGIS errors are common.
- Open the FeatureServer URL in a browser/curl to confirm the service is alive and the layer schema unchanged.
- Update the openbb_imf provider to the latest version in case the URL moved.
- Ensure network egress to services9.arcgis.com is permitted.
Defensive patterns
Strategy: retry
Try / catch
for attempt in range(3):
try:
ports = await obb.economy.imf.port_info()
break
except OpenBBError as e:
msg = str(e)
if 'Failed to fetch data' in msg and attempt < 2:
await asyncio.sleep(2 ** attempt)
else:
raise Prevention
- Cache the ports database locally; it changes rarely
- Back off on 429 rather than hammering ArcGIS
When it happens
Trigger: GET to services9.arcgis.com PortWatch_ports_database FeatureServer returning 4xx/5xx: service outage, throttling (429), changed layer, or blocked egress.
Common situations: ArcGIS Online incidents; proxies/firewalls blocking services9.arcgis.com; heavy polling triggering ArcGIS rate limits; stale provider version pointing at a retired service URL.
Related errors
- Failed to fetch data: {response.status}
- Failed to fetch ports data: {response.status} - {response.re
- Failed to fetch data: {response.status}
- No data found in the response.
- {e}
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/4864e69034f78225.
Report an issue: GitHub.