{"record":{"id":"4ea0ee5a972a2e6d","repo":"OpenBB-finance/OpenBB","slug":"error-fetching-port-activity-data-e-e-args","errorCode":null,"errorMessage":"Error fetching port activity data: {e} -> {e.args}","messagePattern":"Error fetching port activity data: (.+?) -> (.+?)","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/imf/openbb_imf/utils/port_watch_helpers.py","lineNumber":287,"sourceCode":"                )\n            if response.content is None:\n                raise OpenBBError(\"No content returned from the request.\")\n            content = await response.text()\n\n        df = read_csv(StringIO(content))\n        df.date = to_datetime(df.date).dt.date\n        df = df.drop(\n            columns=[\n                d\n                for d in [\"ObjectId\", \"GlobalID\", \"year\", \"month\", \"day\"]\n                if d in df.columns\n            ]\n        )\n\n        return df.to_dict(orient=\"records\")\n\n    except Exception as e:\n        raise OpenBBError(f\"Error fetching port activity data: {e} -> {e.args}\") from e\n\n\n@alru_cache(maxsize=125)\nasync def get_daily_port_activity_data(\n    port_id, start_date: str | None = None, end_date: str | None = None\n) -> list:\n    \"\"\"Get the daily port activity data for a specific port ID.\n\n    Parameters\n    ----------\n    port_id : str\n        The port ID for which to fetch daily activity data.\n\n    Returns\n    -------\n    list\n        A list of dictionaries, each representing daily activity data for the specified port.\n    \"\"\"","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/utils/port_watch_helpers.py#L269-L305","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nrecords = await get_all_daily_port_activity_data()\n\n# after\ntry:\n    records = await get_all_daily_port_activity_data()\nexcept OpenBBError as e:\n    cause = e.__cause__\n    if isinstance(cause, (ConnectionError, TimeoutError)):\n        raise  # retryable upstream\n    raise  # schema/parse: inspect cause args before proceeding","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    records = await get_all_daily_port_activity_data()\nexcept OpenBBError as e:\n    cause = e.__cause__\n    msg = f'{cause}' if cause else str(e)\n    if any(k in msg for k in ('status', 'content', 'timeout', '429', '500')):\n        raise Retryable(msg) from e\n    raise SchemaDrift(msg) from e  # pandas parse errors mean column layout changed","preventionTips":["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."],"tags":["imf","port-watch","wrapper","pandas","bulk-download"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}