OpenBB-finance/OpenBB · error · OpenBBError

Error in fetching chokepoint data: {e} -> {e.args[0]}

Error message

Error in fetching chokepoint data: {e} -> {e.args[0]}

What it means

Outer catch-all around the chokepoints aggregation: any exception escaping the gather/inspection block (including the re-raised per-chokepoint and empty-result OpenBBErrors) is re-wrapped with 'Error in fetching chokepoint data: {e} -> {e.args[0]}'. Note the message indexes e.args[0] — if the wrapped exception has no args this itself raises IndexError, masking the original error.

Source

Thrown at openbb_platform/providers/imf/openbb_imf/utils/port_watch_helpers.py:234

            raise OpenBBError(f"Failed to fetch data for {chokepoint_id}: {e}") from e

    try:
        gather_results = await asyncio.gather(
            *[_get_one_chokepoint_data(cp) for cp in chokepoints],
            return_exceptions=True,
        )

        for result in gather_results:
            if isinstance(result, (OpenBBError, Exception)):
                raise result

        if not chokepoints_data:
            raise OpenBBError("All requests were returned empty.")

        return chokepoints_data

    except Exception as e:
        raise OpenBBError(
            f"Error in fetching chokepoint data: {e} -> {e.args[0]}"
        ) from e


@alru_cache(maxsize=1)
async def get_all_daily_port_activity_data() -> list:
    """Get all port activity data as a bulk download CSV.

    This function fetches a large file containing daily global port activity.
    Expect the file to be around 800 MB in size.

    Returns
    -------
    list
        A list of dictionaries, each representing a row of port activity data.
    """
    # pylint: disable=import-outside-toplevel
    from io import StringIO  # noqa

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Read the innermost cause via __cause__/args of the caught OpenBBError rather than trusting the formatted text.
  2. As a provider fix, use e.args[0] if e.args else str(e) to avoid the IndexError-on-no-args bug.
  3. Retry once for transient network causes identified in the inner message.

Example fix

# before (provider, port_watch_helpers.py)
except Exception as e:
    raise OpenBBError(f"Error in fetching chokepoint data: {e} -> {e.args[0]}") from e

# after
except Exception as e:
    inner = e.args[0] if e.args else str(e)
    raise OpenBBError(f"Error in fetching chokepoint data: {e} -> {inner}") from e
Defensive patterns

Strategy: try-catch

Try / catch

try:
    data = await get_all_chokepoints_data(start, end)
except OpenBBError as e:
    root = e.__cause__ or e
    # root may itself be an IndexError from e.args[0] formatting — unwrap fully
    while isinstance(root, Exception) and root.__cause__:
        root = root.__cause__
    log.error('chokepoint fetch failed: %s', root)

Prevention

When it happens

Trigger: Any failure inside the chokepoint sweep; in particular wrapping an exception constructed with no args (e.g. bare ValueError()), which makes the f-string itself crash with IndexError before the raise completes.

Common situations: Diagnosing chokepoint outages where the reported 'inner message' is actually an IndexError from e.args[0]; chained wrappers making the true root cause harder to read.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/e4d8df4b077d97e3. Report an issue: GitHub.