{"record":{"id":"ecf3bcf8df1cdd9a","repo":"OpenBB-finance/OpenBB","slug":"unexpected-response-format-expected-a-dictionary-ecf3bc","errorCode":null,"errorMessage":"Unexpected response format, expected a dictionary, got {response.__class__.__name__}","messagePattern":"Unexpected response format, expected a dictionary, got (.+?)","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/intrinio/openbb_intrinio/models/historical_market_cap.py","lineNumber":111,"sourceCode":"        async def get_one(symbol):\n            \"\"\"Get data for one symbol.\"\"\"\n            url_params = (\n                f\"{symbol}/marketcap?{frequency}start_date={start_date}\"\n                f\"&end_date={end_date}&page_size=10000\"\n                f\"&api_key={api_key}\"\n            )\n            url = f\"{base_url}{url_params}\"\n            try:\n                response = await amake_request(url, response_callback=response_callback)\n            except OpenBBError as e:\n                if \"Cannot look up this item/identifier combination\" in str(e):\n                    msg = f\"Symbol not found: {symbol}\"\n                    messages.append(msg)\n                    return\n                raise e from e\n\n            if not isinstance(response, dict):\n                raise OpenBBError(\n                    f\"Unexpected response format, expected a dictionary, got {response.__class__.__name__}\"\n                )\n\n            if not response:\n                msg = f\"No data found for symbol: {symbol}\"\n                messages.append(msg)\n\n            if response.get(\"historical_data\"):\n                data = response.get(\"historical_data\", {})\n                result = [\n                    {\"symbol\": symbol, **item} for item in data if item.get(\"value\")\n                ]\n                results.extend(result)\n\n            return\n\n        await asyncio.gather(*[get_one(symbol) for symbol in symbols])\n","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/intrinio/openbb_intrinio/models/historical_market_cap.py#L93-L129","documentation":"OpenBBError raised in the historical market cap fetcher when amake_request with a response_callback returned something that is not a dict (e.g. a list, str, or None). The callback is expected to yield the parsed JSON object, so this means Intrinio's historical_data endpoint returned an unexpected top-level shape - typically a list payload or an error body not shaped like a dict.","triggerScenarios":"equity/fundamental/market_cap(symbol=X, provider='intrinio') where the underlying $ symbol historical_data/value response is a JSON array or HTML/plain-text error (proxy page, gateway error), making response a non-dict; also possible if response_callback returns the results list instead of parsed JSON.","commonSituations":"Corporate actions causing the API to return an array of entries instead of the usual object; intermediary proxies returning HTML 502 pages; Intrinio A/B schema changes; symbols with special characters producing redirect bodies.","solutions":["curl the URL 'https://api-v2.intrinio.com/historical_data/$SYMBOL/market_cap?api_key=KEY' to inspect the actual top-level JSON type.","If a proxy/gateway interferes, bypass it or fix headers.","Retry with the unescaped plain ticker (no $ prefix) - the fetcher builds the URL itself.","Report to OpenBB with the symbol if Intrinio legitimately returns a list shape."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"# probe the endpoint shape for one symbol before batch use\nimport urllib.request, json\nwith urllib.request.urlopen(f'https://api-v2.intrinio.com/historical_data/$DJI/historical_data/level?api_key={key}') as r:\n    payload = json.load(r)\nassert isinstance(payload, dict), f'unexpected shape: {type(payload)}'","typeGuard":"def is_dict_payload(x) -> bool:\n    return isinstance(x, dict)","tryCatchPattern":"from openbb_core.provider.exceptions import OpenBBError\ntry:\n    res = obb.equity.fundamental.market_cap(symbol=sym, provider='intrinio')\nexcept OpenBBError as e:\n    if 'expected a dictionary' in str(e):\n        log.error('intrinio returned non-dict payload for %s (proxy or API change?)', sym)\n    raise","preventionTips":["Check for corporate-event schema changes on new symbols","Bypass HTML-injecting proxies for api-v2.intrinio.com","Probe one symbol's payload shape before batch processing"],"tags":["intrinio","response-format","market-cap","type-error"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}