OpenBB-finance/OpenBB · error · OpenBBError
Failed to fetch port activity data: {response.status} - {res
Error message
Failed to fetch port activity data: {response.status} - {response.reason} What it means
Raised by get_all_daily_port_activity_data when the bulk CSV download (~800 MB) from the ArcGIS hub dataset api/v3 downloads endpoint returns a non-200 status. The message includes both status and reason phrase. This is a large, single-shot download with a 120-second timeout, so server-side failures and throttles are relatively common.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/utils/port_watch_helpers.py:267
A list of dictionaries, each representing a row of port activity data.
"""
# pylint: disable=import-outside-toplevel
from io import StringIO # noqa
from openbb_core.app.model.abstract.error import OpenBBError
from openbb_core.provider.utils.helpers import get_async_requests_session
from pandas import read_csv, to_datetime
url = (
"https://hub.arcgis.com/api/v3/datasets/959214444157458aad969389b3ebe1a0_0/"
+ "downloads/data?format=csv&spatialRefId=4326&where=1%3D1"
)
content = ""
try:
async with await get_async_requests_session(
timeout=120
) as session, await session.get(url) as response:
if response.status != 200:
raise OpenBBError(
f"Failed to fetch port activity data: {response.status} - {response.reason}"
)
if response.content is None:
raise OpenBBError("No content returned from the request.")
content = await response.text()
df = read_csv(StringIO(content))
df.date = to_datetime(df.date).dt.date
df = df.drop(
columns=[
d
for d in ["ObjectId", "GlobalID", "year", "month", "day"]
if d in df.columns
]
)
return df.to_dict(orient="records")
View on GitHub (pinned to 3e071fcc2c)
Solutions
- Retry with backoff — 429/5xx on this endpoint typically clear; keep the 120s+ timeout.
- Verify the dataset URL still resolves (curl -I) and check IMF Port Watch for dataset announcements.
- If bandwidth-constrained, prefer the per-port endpoint (get_daily_port_activity_data) for the ports you actually need.
Defensive patterns
Strategy: retry
Validate before calling
import requests
HEAD = 'https://hub.arcgis.com/api/v3/datasets/959214444157458aad969389b3ebe1a0_0/'
ok = requests.head(HEAD + 'downloads/data?format=csv&spatialRefId=4326&where=1%3D1',
timeout=15, allow_redirects=True).status_code == 200 Try / catch
try:
records = await get_all_daily_port_activity_data()
except OpenBBError as e:
if 'Failed to fetch port activity data' in str(e):
raise Retryable(str(e)) from e # 429/5xx on the ~800MB download: backoff heavily
raise Prevention
- Run the bulk download at most once per day and cache results (it is ~800 MB).
- Prefer per-port queries when you need only a few ports.
When it happens
Trigger: Calling the bulk port-activity fetch while ArcGIS throttles the large download (429), the dataset id in the URL was retired (404), or the service is down (5xx).
Common situations: Repeated daily bulk pulls hitting transfer limits, corporate egress proxies rejecting very large responses, stale hardcoded dataset id after an ArcGIS migration.
Related errors
- Failed to fetch data: {response.status}
- No content returned from the request.
- Error fetching port activity data: {e} -> {e.args}
- Failed to fetch data: {response.status}
- No data found in the response.
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/3ce724dcfae073fb.
Report an issue: GitHub.