{"record":{"id":"eeb59dc27bae1b24","repo":"OpenBB-finance/OpenBB","slug":"expecting-a-list-of-dictionaries-and-received-a-di","errorCode":null,"errorMessage":"Expecting a list of dictionaries and received a dictionary.","messagePattern":"Expecting a list of dictionaries and received a dictionary\\.","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/econdb/openbb_econdb/utils/helpers.py","lineNumber":528,"sourceCode":"            try:\n                response = await amake_requests(urls, session=session)\n            finally:\n                await session.close()\n    else:\n        response = await amake_requests(urls)\n    return response\n\n\ndef parse_context(  # pylint: disable=R0912, R0914, R0915\n    response: list[dict], latest: bool = False, with_metadata: bool = False\n) -> DataFrame | tuple[DataFrame, dict]:\n    \"\"\"Parse the output from `get_context()`, and optionally return the metadata.\"\"\"\n    metadata = {}\n    results = DataFrame()\n    if response is None:\n        raise OpenBBError(\"No data was in the response\")\n    if not isinstance(response, list):\n        raise OpenBBError(\"Expecting a list of dictionaries and received a dictionary.\")\n    for item in response:\n        symbol = item.get(\"id\", \"\")\n        _symbol = symbol.split(\"~\")[0].replace(\"19\", \"\")\n        temp_unit = \"\"\n        temp_meta = item.get(\"td\", {})\n        temp_data = item.get(\"dataarray\", [])\n        temp_transform = symbol.split(\"~\")[1] if \"~\" in symbol else \"\"\n        temp_country = item.get(\"geography\", {}).get(\"name\", \"\")\n        temp_country = temp_country.replace(\" (19 countries)\", \"\")\n        # We need the metadata to process the results.\n        if temp_meta:\n            temp_unit = temp_meta.get(\"units\", \"\")\n            temp_scale = temp_meta.get(\"scale\", \"\")\n            if temp_transform:\n                if temp_transform in [\"TOYA\", \"TPOP\", \"TPGP\"]:\n                    temp_unit = \"Percent\"\n                if temp_transform == \"TUSD\":\n                    temp_unit = \"USD\"","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/econdb/openbb_econdb/utils/helpers.py#L510-L546","documentation":"parse_context expects a list of series dictionaries (one per requested ticker) but raises OpenBBError when the response is a single dict. The EconDB series API returns a JSON object (not a list) in error conditions — e.g. an error payload keyed by 'error'/'detail' — so this message usually masks an upstream API error such as a bad token, unknown ticker, or rate limit.","triggerScenarios":"An econdb get_context call where the API responds with a dict-shaped error document: invalid token in the URL, removed tickers, or throttling — the fetch succeeds (HTTP 200-ish) but the body shape betrays the error.","commonSituations":"Expired temp token cached and reused; ticker renamed upstream; heavy usage tripping API limits that return structured errors with 200 status.","solutions":["Inspect the raw response from https://www.econdb.com/api/series/ for your URL to see the dict error body and its message.","Refresh credentials: set your own econdb_api_key, or clear the token cache so create_token runs again.","Re-validate ticker symbols and their transform suffixes.","Reduce request frequency and retry after limits reset."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"import httpx\nr = httpx.get(f'https://www.econdb.com/api/series/?ticker=%5B{ticker}%5D&format=json&token={token}')\nbody = r.json()\nif isinstance(body, dict):\n    raise RuntimeError(f'econdb returned an error object: {body}')","typeGuard":"def is_context_response(x) -> bool:\n    \"\"\"Type guard: parse_context requires list[dict]; a dict means an API error payload.\"\"\"\n    return isinstance(x, list) and not isinstance(x, dict)","tryCatchPattern":"from openbb_core.app.model.obbject import OpenBBError\ntry:\n    df = parse_context(response)\nexcept OpenBBError as e:\n    if 'Expecting a list' in str(e):\n        # response is actually an error dict - inspect it for 'error'/'detail'\n        logger.error(f'econdb API error body: {response}')\n    raise","preventionTips":["Inspect dict-shaped responses - they carry the real API error (bad token, unknown ticker, throttle).","Refresh the token / clear cache when this appears after working before.","Log the raw body alongside the exception for diagnosis."],"tags":["type-mismatch","api-contract","econdb","auth"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}