{"record":{"id":"5fa203bc79a6a7c2","repo":"OpenBB-finance/OpenBB","slug":"unexpected-format-of-the-response-expected-dic","errorCode":null,"errorMessage":"Unexpected format of the response. -> Expected dict, got {str(response.__class__.__name__)}","messagePattern":"Unexpected format of the response\\. -> Expected dict, got (.+?)","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/econdb/openbb_econdb/models/port_volume.py","lineNumber":90,"sourceCode":"    async def aextract_data(\n        query: EconDbPortVolumeQueryParams,\n        credentials: dict[str, str] | None,\n        **kwargs: Any,\n    ) -> dict:\n        \"\"\"Extract the raw data.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        from openbb_core.provider.utils.helpers import amake_request\n\n        url = \"https://www.econdb.com/static/openbb/shipping.json\"\n\n        try:\n            response = await amake_request(url)\n        except Exception as e:\n            raise OpenBBError(\"There was an error with the HTTP request\") from e\n\n        if isinstance(response, dict):\n            return response\n        raise OpenBBError(\n            f\"Unexpected format of the response. -> Expected dict, got {str(response.__class__.__name__)}\"\n        )\n\n    @staticmethod\n    def transform_data(\n        query: EconDbPortVolumeQueryParams,\n        data: dict,\n        **kwargs: Any,\n    ) -> list[EconDbPortVolumeData]:\n        \"\"\"Transform the data.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        from openbb_econdb.utils.helpers import COUNTRY_MAP\n        from pandas import DataFrame, concat, to_datetime\n\n        df: DataFrame = DataFrame()\n        res = data.copy()\n\n        if not res:","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/econdb/openbb_econdb/models/port_volume.py#L72-L108","documentation":"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.","triggerScenarios":"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.","commonSituations":"Upstream dataset format change on EconDB's side; captive portals returning odd JSON; a future provider version expecting a different shape.","solutions":["Fetch the URL manually and inspect the top-level JSON type to confirm what is being served.","Retry later in case of a transient bad payload.","Update/reinstall the openbb-econdb provider (pip install -U openbb-econdb) — format migrations are fixed provider-side.","If the shape genuinely changed, open an issue with the OpenBB team."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"import httpx\nr = httpx.get('https://www.econdb.com/static/openbb/shipping.json', timeout=10)\npayload = r.json()\nassert isinstance(payload, dict) and 'Ports' in payload, f'unexpected shipping.json shape: {type(payload).__name__}'","typeGuard":"def is_shipping_payload(x) -> bool:\n    \"\"\"Type guard: shipping.json must be a dict containing a Ports list.\"\"\"\n    return isinstance(x, dict) and isinstance(x.get('Ports'), list)","tryCatchPattern":"from openbb_core.app.model.obbject import OpenBBError\ntry:\n    res = obb.economy.port_volume(provider='econdb')\nexcept OpenBBError as e:\n    if 'Unexpected format of the response' in str(e):\n        logger.error('econdb shipping.json contract changed - pin/upgrade provider')\n    raise","preventionTips":["Pin provider versions in production so upstream format changes surface in tests first.","Add a smoke test asserting the shipping.json shape before daily jobs."],"tags":["type-mismatch","port-volume","econdb","api-contract"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}