{"record":{"id":"3ce724dcfae073fb","repo":"OpenBB-finance/OpenBB","slug":"failed-to-fetch-port-activity-data-response-stat","errorCode":null,"errorMessage":"Failed to fetch port activity data: {response.status} - {response.reason}","messagePattern":"Failed to fetch port activity data: (.+?) - (.+?)","errorType":"http","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/imf/openbb_imf/utils/port_watch_helpers.py","lineNumber":267,"sourceCode":"        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\n    from openbb_core.app.model.abstract.error import OpenBBError\n    from openbb_core.provider.utils.helpers import get_async_requests_session\n    from pandas import read_csv, to_datetime\n\n    url = (\n        \"https://hub.arcgis.com/api/v3/datasets/959214444157458aad969389b3ebe1a0_0/\"\n        + \"downloads/data?format=csv&spatialRefId=4326&where=1%3D1\"\n    )\n    content = \"\"\n    try:\n        async with await get_async_requests_session(\n            timeout=120\n        ) as session, await session.get(url) as response:\n            if response.status != 200:\n                raise OpenBBError(\n                    f\"Failed to fetch port activity data: {response.status} - {response.reason}\"\n                )\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","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/utils/port_watch_helpers.py#L249-L285","documentation":"Raised by get_all_daily_port_activity_data when the bulk CSV download (~800 MB) from the ArcGIS hub dataset api/v3 downloads endpoint returns a non-200 status. The message includes both status and reason phrase. This is a large, single-shot download with a 120-second timeout, so server-side failures and throttles are relatively common.","triggerScenarios":"Calling the bulk port-activity fetch while ArcGIS throttles the large download (429), the dataset id in the URL was retired (404), or the service is down (5xx).","commonSituations":"Repeated daily bulk pulls hitting transfer limits, corporate egress proxies rejecting very large responses, stale hardcoded dataset id after an ArcGIS migration.","solutions":["Retry with backoff — 429/5xx on this endpoint typically clear; keep the 120s+ timeout.","Verify the dataset URL still resolves (curl -I) and check IMF Port Watch for dataset announcements.","If bandwidth-constrained, prefer the per-port endpoint (get_daily_port_activity_data) for the ports you actually need."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import requests\nHEAD = 'https://hub.arcgis.com/api/v3/datasets/959214444157458aad969389b3ebe1a0_0/'\nok = requests.head(HEAD + 'downloads/data?format=csv&spatialRefId=4326&where=1%3D1',\n                  timeout=15, allow_redirects=True).status_code == 200","typeGuard":null,"tryCatchPattern":"try:\n    records = await get_all_daily_port_activity_data()\nexcept OpenBBError as e:\n    if 'Failed to fetch port activity data' in str(e):\n        raise Retryable(str(e)) from e  # 429/5xx on the ~800MB download: backoff heavily\n    raise","preventionTips":["Run the bulk download at most once per day and cache results (it is ~800 MB).","Prefer per-port queries when you need only a few ports."],"tags":["imf","port-watch","bulk-download","arcgis","http"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}