OpenBB-finance/OpenBB · error · OpenBBError

Failed to fetch data: {response.status}

Error message

Failed to fetch data: {response.status}

What it means

Raised in `afetch_data` of the IMF maritime chokepoint info fetcher when the ArcGIS FeatureServer behind IMF PortWatch returns a non-200 HTTP status for the chokepoints GeoJSON query. Any transport-layer problem surfaces as this single status-code error; the surrounding `except` re-wraps non-OpenBB exceptions into `OpenBBError` as well.

Source

Thrown at openbb_platform/providers/imf/openbb_imf/models/maritime_chokepoint_info.py:164

        query: ImfMaritimeChokePointInfoQueryParams,
        credentials: dict[str, str] | None,
        **kwargs: Any,
    ) -> dict:
        """Extract the raw data from the IMF Port Watch API."""
        # pylint: disable=import-outside-toplevel
        from openbb_core.provider.utils.helpers import get_async_requests_session

        url = (
            "https://services9.arcgis.com/weJ1QsnbMYJlCHdG/arcgis/rest/services/"
            "PortWatch_chokepoints_database/FeatureServer/0/query?outFields=*&where=1%3D1&f=geojson"
        )

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

                return await response.json()

        except Exception as e:
            raise OpenBBError(e) from e

    @staticmethod
    def transform_data(
        query: ImfMaritimeChokePointInfoQueryParams,
        data: dict,
        **kwargs: Any,
    ) -> list[ImfMaritimeChokePointInfoData]:
        """Transform the raw data into a list of ImfMaritimeChokePointInfoData."""
        if not data or "features" not in data:
            raise OpenBBError("No data found in the response.")

        return [
            ImfMaritimeChokePointInfoData(**feature["properties"])

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Retry after a short delay — transient ArcGIS 5xx/429 responses usually clear.
  2. Verify the URL still resolves: open the FeatureServer query in a browser or curl and check the JSON envelope.
  3. Check ArcGIS Online health / IMF PortWatch status pages for outages.
  4. If behind a proxy, ensure aiohttp session honors your proxy env vars and the host is allow-listed.
Defensive patterns

Strategy: retry

Try / catch

for attempt in range(3):
    try:
        info = await obb.economy.imf.maritime_chokepoint_info()
        break
    except OpenBBError as e:
        if 'Failed to fetch data' in str(e) and attempt < 2:
            await asyncio.sleep(2 ** attempt)
            continue
        raise

Prevention

When it happens

Trigger: GET to services9.arcgis.com PortWatch_chokepoints_database FeatureServer returning 4xx/5xx: ArcGIS outage or maintenance, rate limiting (HTTP 429), or a changed/retired service URL after an ArcGIS redesign.

Common situations: Esri ArcGIS Online incidents; corporate proxies or firewalls blocking services9.arcgis.com; the FeatureServer layer ID changing; bursts of requests tripping ArcGIS throttling.

Related errors


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