OpenBB-finance/OpenBB · error · OpenBBError
Error fetching port activity data: {e} -> {e.args}
Error message
Error fetching port activity data: {e} -> {e.args} What it means
Catch-all wrapper at the end of get_all_daily_port_activity_data: any exception during the bulk download or the pandas post-processing (read_csv, to_datetime, column drops) is re-raised as OpenBBError with the exception and its args tuple. Since this function is alru_cache(maxsize=1), a failed result is not cached and the next call retries the whole download.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/utils/port_watch_helpers.py:287
)
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")
except Exception as e:
raise OpenBBError(f"Error fetching port activity data: {e} -> {e.args}") from e
@alru_cache(maxsize=125)
async def get_daily_port_activity_data(
port_id, start_date: str | None = None, end_date: str | None = None
) -> list:
"""Get the daily port activity data for a specific port ID.
Parameters
----------
port_id : str
The port ID for which to fetch daily activity data.
Returns
-------
list
A list of dictionaries, each representing daily activity data for the specified port.
"""View on GitHub (pinned to 3e071fcc2c)
Solutions
- Unwrap __cause__ to see whether it is network (retry) or a pandas parse error (schema change).
- For schema changes, fetch the CSV directly and adapt column handling, or pin to a provider version updated for the new layout.
- For memory issues, use the per-port endpoint instead of the bulk file.
Example fix
# before
records = await get_all_daily_port_activity_data()
# after
try:
records = await get_all_daily_port_activity_data()
except OpenBBError as e:
cause = e.__cause__
if isinstance(cause, (ConnectionError, TimeoutError)):
raise # retryable upstream
raise # schema/parse: inspect cause args before proceeding Defensive patterns
Strategy: try-catch
Try / catch
try:
records = await get_all_daily_port_activity_data()
except OpenBBError as e:
cause = e.__cause__
msg = f'{cause}' if cause else str(e)
if any(k in msg for k in ('status', 'content', 'timeout', '429', '500')):
raise Retryable(msg) from e
raise SchemaDrift(msg) from e # pandas parse errors mean column layout changed Prevention
- Inspect e.args in the message to separate network from pandas failures.
- Pin a provider version compatible with the current CSV schema; watch for IMF dataset refreshes.
When it happens
Trigger: CSV schema drift (renamed/missing 'date' or dropped ObjectId/GlobalID columns breaking read_csv/to_datetime), timeouts, and the non-200/empty-content raises from errors 615/616 all landing here.
Common situations: IMF/ArcGIS changing the CSV column layout after a dataset refresh; memory pressure parsing an ~800 MB file; slow disks making the parse exceed limits.
Related errors
- Error in fetching chokepoint data: {e} -> {e.args[0]}
- Failed to fetch port activity data: {response.status} - {res
- No content returned from the request.
- Country code is not supported by IMF Port Watch.
- Failed to fetch data: {response.status}
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/4ea0ee5a972a2e6d.
Report an issue: GitHub.