OpenBB-finance/OpenBB · error · OpenBBError

Unexpected format of the response. -> Expected dict, got {st

Error message

Unexpected format of the response. -> Expected dict, got {str(response.__class__.__name__)}

What it means

After successfully fetching shipping.json, EconDbPortVolumeFetcher checks isinstance(response, dict) and raises OpenBBError('Unexpected format of the response. -> Expected dict, got <TypeName>') when the parsed JSON is not an object. The dataset is expected to be a dict with a 'Ports' key plus per-port series; receiving a list or a plain string means the payload is not the known dataset.

Source

Thrown at openbb_platform/providers/econdb/openbb_econdb/models/port_volume.py:90

    async def aextract_data(
        query: EconDbPortVolumeQueryParams,
        credentials: dict[str, str] | None,
        **kwargs: Any,
    ) -> dict:
        """Extract the raw data."""
        # pylint: disable=import-outside-toplevel
        from openbb_core.provider.utils.helpers import amake_request

        url = "https://www.econdb.com/static/openbb/shipping.json"

        try:
            response = await amake_request(url)
        except Exception as e:
            raise OpenBBError("There was an error with the HTTP request") from e

        if isinstance(response, dict):
            return response
        raise OpenBBError(
            f"Unexpected format of the response. -> Expected dict, got {str(response.__class__.__name__)}"
        )

    @staticmethod
    def transform_data(
        query: EconDbPortVolumeQueryParams,
        data: dict,
        **kwargs: Any,
    ) -> list[EconDbPortVolumeData]:
        """Transform the data."""
        # pylint: disable=import-outside-toplevel
        from openbb_econdb.utils.helpers import COUNTRY_MAP
        from pandas import DataFrame, concat, to_datetime

        df: DataFrame = DataFrame()
        res = data.copy()

        if not res:

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Fetch the URL manually and inspect the top-level JSON type to confirm what is being served.
  2. Retry later in case of a transient bad payload.
  3. Update/reinstall the openbb-econdb provider (pip install -U openbb-econdb) — format migrations are fixed provider-side.
  4. If the shape genuinely changed, open an issue with the OpenBB team.
Defensive patterns

Strategy: type-guard

Validate before calling

import httpx
r = httpx.get('https://www.econdb.com/static/openbb/shipping.json', timeout=10)
payload = r.json()
assert isinstance(payload, dict) and 'Ports' in payload, f'unexpected shipping.json shape: {type(payload).__name__}'

Type guard

def is_shipping_payload(x) -> bool:
    """Type guard: shipping.json must be a dict containing a Ports list."""
    return isinstance(x, dict) and isinstance(x.get('Ports'), list)

Try / catch

from openbb_core.app.model.obbject import OpenBBError
try:
    res = obb.economy.port_volume(provider='econdb')
except OpenBBError as e:
    if 'Unexpected format of the response' in str(e):
        logger.error('econdb shipping.json contract changed - pin/upgrade provider')
    raise

Prevention

When it happens

Trigger: economy.port_volume(provider='econdb') when shipping.json is served as a JSON array/scalar — e.g. the static file was replaced, an error payload was served with 200, or a proxy returned a JSON-encoded string.

Common situations: Upstream dataset format change on EconDB's side; captive portals returning odd JSON; a future provider version expecting a different shape.

Related errors


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