OpenBB-finance/OpenBB · error · OpenBBError

Failed to fetch data: {response.status}

Error message

Failed to fetch data: {response.status}

What it means

Raised during the first page of the Port Watch chokepoints fetch (ArcGIS hub feature service): the async HTTP status was not 200, and the helper converts it to an OpenBBError with the numeric status. Any 4xx/5xx (auth-less service, so typically 429/5xx/404 after endpoint changes) lands here.

Source

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

            if start_date is not None and end_date is not None
            else (
                CHOKEPOINTS_BASE_URL
                + f"where=portid%20%3D%20%27{chokepoint_id.upper()}%27&"
                + f"outFields=*&orderByFields=date&returnZ=true&resultOffset={offset}&resultRecordCount=1000"
                + "&maxRecordCountFactor=5&outSR=&f=json"
            )
        )

    offset: int = 0
    output: dict = {}
    url = get_chokepoints_url(offset)

    async with await get_async_requests_session() as session:
        async with await session.get(url) as response:
            data: dict = {}

            if response.status != 200:
                raise OpenBBError(f"Failed to fetch data: {response.status}")
            data = await response.json()

        if "features" in data:
            output = data.copy()

        while data.get("exceededTransferLimit") is True:
            offset += len(data["features"])
            url = get_chokepoints_url(offset)

            async with await session.get(url) as response:
                data = {}
                if response.status != 200:
                    raise OpenBBError(f"Failed to fetch data: {response.status}")
                data = await response.json()

            if "features" in data:
                output["features"].extend(data["features"])

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Retry with backoff — transient ArcGIS 5xx/429 responses usually clear within seconds to minutes.
  2. Open the constructed URL (from get_chokepoints_url) in a browser/curl to check whether the dataset moved.
  3. Check IMF Port Watch status pages for announced ArcGIS migrations.
Defensive patterns

Strategy: retry

Validate before calling

import requests
ok = requests.get(get_chokepoints_url(0), timeout=10).status_code == 200

Try / catch

try:
    pts = await get_chokepoints()
except OpenBBError as e:
    if 'Failed to fetch data:' in str(e):
        raise Retryable(str(e)) from e  # transient ArcGIS status; backoff and retry
    raise

Prevention

When it happens

Trigger: Calling get_chokepoints / the chokepoints listing function when the ArcGIS endpoint is degraded, rate-limiting (429), or the URL/dataset id changed (404).

Common situations: ArcGIS hub maintenance windows, heavy scraping triggering throttles, breaking changes to the dataset id baked into get_chokepoints_url.

Related errors


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