{"record":{"id":"2d91ca880de5e022","repo":"OpenBB-finance/OpenBB","slug":"e","errorCode":null,"errorMessage":"e","messagePattern":"e","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/econdb/openbb_econdb/models/export_destinations.py","lineNumber":84,"sourceCode":"        MAP_COUNTRY = {v: k for k, v in COUNTRY_MAP.items()}\n\n        async def get_one_country(c):\n            \"\"\"Get data for one country.\"\"\"\n            c = c.upper() if len(c) == 2 else c.lower()\n            if len(c) != 2:\n                c = COUNTRY_MAP.get(c, c)\n                if len(c) != 2 or c.upper() not in MAP_COUNTRY:\n                    messages.append(f\"Invalid country code -> {c}\")\n                    return\n\n            URL = f\"https://www.econdb.com/widgets/top-trade-items/data/?country={c.upper()}&split_by=country\"\n            result: list = []\n            row: dict = {}\n            try:\n                res = await amake_request(URL)\n            except ContentTypeError as e:\n                if len(countries) == 1:\n                    raise OpenBBError(e) from e\n                messages.append(f\"No data available for the country -> {c}\")\n                return\n\n            plots = res.get(\"plots\", [])  # type: ignore\n            data = plots[0].pop(\"data\", []) if plots else []\n            meta = plots[0] if plots else {}\n\n            if not data or (len(data) == 1 and data[0].get(\"Value million USD\") == 0):\n                messages.append(f\"No data available for the country -> {c}\")\n                return\n\n            origin_country = MAP_COUNTRY.get(c, c)\n\n            for item in data:\n                row = {\n                    \"origin_country\": origin_country.replace(\"_\", \" \").title(),\n                    **item,\n                    \"units\": (","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/econdb/openbb_econdb/models/export_destinations.py#L66-L102","documentation":"Thrown by EconDbExportDestinationsFetcher.aextract_data when the request to the EconDB 'top-trade-items' widget URL fails with an httpx ContentTypeError (the server replied with a non-JSON body, e.g. an HTML error/block page) and only a single country was requested. With one country there is nothing to fall back on, so the raw exception is wrapped in OpenBBError and re-raised. With multiple countries the failure is instead collected as a per-country message.","triggerScenarios":"Calling economy.export_destinations with a single country (e.g. country='portugal') while www.econdb.com/widgets/top-trade-items/data/ returns HTML instead of JSON — rate limiting, Cloudflare interstitial, or a removed widget endpoint.","commonSituations":"Running repeated scripted calls that trip rate limits; corporate proxies returning HTML error pages; EconDB changing the widget API; querying from a flagged IP.","solutions":["Retry after a short delay — transient rate-limit/Cloudflare HTML responses are the most common cause.","Confirm the widget URL still returns JSON in a browser/curl: https://www.econdb.com/widgets/top-trade-items/data/?country=PT&split_by=country.","Pass multiple countries (country='portugal,spain') so a single-country failure degrades to a warning message instead of an exception.","If the endpoint now returns HTML permanently, the widget API changed — pin/update the openbb-econdb provider package or open an issue."],"exampleFix":"# before\nobb.economy.export_destinations(provider='econdb', country='pt')\n\n# after - multiple countries degrade gracefully instead of raising\nobb.economy.export_destinations(provider='econdb', country='pt,es')","handlingStrategy":"try-catch","validationCode":"from openbb_econdb.utils.helpers import COUNTRY_MAP\ncountries = ['pt']\nmap_country = {v: k for k, v in COUNTRY_MAP.items()}\nassert all(len(c) == 2 and c.upper() in map_country for c in countries), 'use valid 2-letter ISO codes'","typeGuard":"def is_valid_iso2(code: str, map_country: dict[str, str]) -> bool:\n    return len(code) == 2 and code.upper() in map_country","tryCatchPattern":"from openbb_core.app.model.obbject import OpenBBError\ntry:\n    res = await obb.economy.export_destinations(provider='econdb', country='pt').to_df() if False else None\nexcept OpenBBError as e:\n    if 'ContentTypeError' in str(e):\n        logger.warning('EconDB widget returned non-JSON; retrying later')\n        raise","preventionTips":["Prefer multi-country requests so single-country failures degrade to warnings.","Rate-limit repeated widget calls; the endpoint is not a documented API.","Check the widget URL manually when debugging to distinguish block pages from outages."],"tags":["network","econdb","export-destinations","content-type","rate-limit"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}