{"record":{"id":"e4d8df4b077d97e3","repo":"OpenBB-finance/OpenBB","slug":"error-in-fetching-chokepoint-data-e-e-args","errorCode":null,"errorMessage":"Error in fetching chokepoint data: {e} -> {e.args[0]}","messagePattern":"Error in fetching chokepoint data: (.+?) -> (.+?)","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/imf/openbb_imf/utils/port_watch_helpers.py","lineNumber":234,"sourceCode":"            raise OpenBBError(f\"Failed to fetch data for {chokepoint_id}: {e}\") from e\n\n    try:\n        gather_results = await asyncio.gather(\n            *[_get_one_chokepoint_data(cp) for cp in chokepoints],\n            return_exceptions=True,\n        )\n\n        for result in gather_results:\n            if isinstance(result, (OpenBBError, Exception)):\n                raise result\n\n        if not chokepoints_data:\n            raise OpenBBError(\"All requests were returned empty.\")\n\n        return chokepoints_data\n\n    except Exception as e:\n        raise OpenBBError(\n            f\"Error in fetching chokepoint data: {e} -> {e.args[0]}\"\n        ) from e\n\n\n@alru_cache(maxsize=1)\nasync def get_all_daily_port_activity_data() -> list:\n    \"\"\"Get all port activity data as a bulk download CSV.\n\n    This function fetches a large file containing daily global port activity.\n    Expect the file to be around 800 MB in size.\n\n    Returns\n    -------\n    list\n        A list of dictionaries, each representing a row of port activity data.\n    \"\"\"\n    # pylint: disable=import-outside-toplevel\n    from io import StringIO  # noqa","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/utils/port_watch_helpers.py#L216-L252","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the innermost cause via __cause__/args of the caught OpenBBError rather than trusting the formatted text.","As a provider fix, use e.args[0] if e.args else str(e) to avoid the IndexError-on-no-args bug.","Retry once for transient network causes identified in the inner message."],"exampleFix":"# before (provider, port_watch_helpers.py)\nexcept Exception as e:\n    raise OpenBBError(f\"Error in fetching chokepoint data: {e} -> {e.args[0]}\") from e\n\n# after\nexcept Exception as e:\n    inner = e.args[0] if e.args else str(e)\n    raise OpenBBError(f\"Error in fetching chokepoint data: {e} -> {inner}\") from e","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    data = await get_all_chokepoints_data(start, end)\nexcept OpenBBError as e:\n    root = e.__cause__ or e\n    # root may itself be an IndexError from e.args[0] formatting — unwrap fully\n    while isinstance(root, Exception) and root.__cause__:\n        root = root.__cause__\n    log.error('chokepoint fetch failed: %s', root)","preventionTips":["Always inspect __cause__, not the formatted message, when diagnosing this wrapper.","Patch the provider to guard e.args[0] with an emptiness check."],"tags":["imf","port-watch","error-handling","chokepoints","wrapper"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}