OpenBB-finance/OpenBB · error · OpenBBError
{task_result}
Error message
{task_result} What it means
After `asyncio.gather(..., return_exceptions=True)` fans out per-chokepoint fetches, the first task result that is an Exception is re-raised as OpenBBError. The message is the inner exception's str — typically a network or HTTP error from one of the concurrent `get_daily_chokepoint_data` calls. One bad chokepoint fails the whole request.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/models/maritime_chokepoint_volume.py:336
chokepoint_ids.append(CHOKEPOINTS_NAME_TO_ID[chokepoint])
elif chokepoint in CHOKEPOINTS_NAME_TO_ID.values() or chokepoint.startswith(
"chokepoint"
):
chokepoint_ids.append(chokepoint)
else:
raise OpenBBError(
f"Invalid chokepoint name: {chokepoint}. Expected one of {list(CHOKEPOINTS_NAME_TO_ID.keys())}."
)
tasks = [
get_one(chokepoint_id) for chokepoint_id in chokepoint_ids if chokepoint_id
]
task_results = await asyncio.gather(*tasks, return_exceptions=True)
for task_result in task_results:
if isinstance(task_result, Exception):
raise OpenBBError(task_result)
if not results:
raise OpenBBError("The response was returned empty with no error message.")
return results
@staticmethod
def transform_data(
query: ImfMaritimeChokePointVolumeQueryParams,
data: list,
**kwargs: Any,
) -> list[ImfMaritimeChokePointVolumeData]:
"""Validate and transform the raw data into the model."""
return [ImfMaritimeChokePointVolumeData(**r) for r in data]
View on GitHub (pinned to 3e071fcc2c)
Solutions
- Inspect the message to identify which chokepoint/request failed; retry that one.
- Reduce the number of simultaneous chokepoints or add your own rate limiting between calls.
- Ensure every id is a real chokepointN (1..24) or canonical name.
- Fetch chokepoints individually so one failure does not discard successful results.
Example fix
# before
maritime_chokepoint_volume(chokepoint='Strait of Hormuz,Suez Canal,Panama Canal', start_date='2024-01-01')
# after (per-chokepoint with individual error handling)
for cp in ['Strait of Hormuz', 'Suez Canal', 'Panama Canal']:
try:
res = await obb.economy.imf.maritime_chokepoint_volume(chokepoint=cp, start_date='2024-01-01')
except OpenBBError as e:
logger.warning('failed %s: %s', cp, e) Defensive patterns
Strategy: fallback
Try / catch
results = []
for cp in chokepoints: # fetch sequentially/individually instead of one fan-out
try:
results += await fetch_one(cp)
except OpenBBError as e:
log.warning('chokepoint %s failed: %s', cp, e) Prevention
- Fetch chokepoints individually when partial results are acceptable
- Throttle concurrent ArcGIS requests to avoid 429s failing the whole gather
When it happens
Trigger: Requesting several chokepoints where at least one per-chokepoint request fails (timeout, 429 throttling from parallel ArcGIS hits, invalid id like 'chokepoint99' producing an HTTP error). Because gather collects exceptions, the raised message corresponds to whichever failed task is iterated first, not necessarily the first chronologically.
Common situations: Fan-out of many chokepoints triggering ArcGIS rate limits; one misspelled chokepointN id; flaky networks under concurrency.
Related errors
- {e}
- {e}
- Failed to fetch data: {response.status}
- Failed to fetch data: {response.status} -> {response.reason}
- Failed to fetch data: {response.status}
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/409da6bc346f2e32.
Report an issue: GitHub.