{"record":{"id":"44cacc9166775f77","repo":"OpenBB-finance/OpenBB","slug":"invalid-symbol-symbol-it-must-have-a-two-let","errorCode":null,"errorMessage":"Invalid symbol: '{symbol}'. It must have a two-letter country code.","messagePattern":"Invalid symbol: '(.+?)'\\. It must have a two-letter country code\\.","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/econdb/openbb_econdb/models/economic_indicators.py","lineNumber":239,"sourceCode":"            # match this defined symbol with any supplied country, and we need to\n            # ignore the transform parameter because it has already been dictated by ~.\n            # We will check if the transform is valid,\n            # and return the symbol as 'level' if it is not.\n            # We will also check if the symbol should have a country,\n            # and if one was supplied.\n            symbol = s.upper()\n            if \"~\" in symbol:\n                _symbol = symbol.split(\"~\")[0]\n                _transform = symbol.split(\"~\")[1]\n                if (\n                    helpers.HAS_COUNTRIES.get(_symbol) is True\n                    and _symbol in helpers.SYMBOL_TO_INDICATOR.values()\n                ):\n                    message = f\"Invalid symbol: '{symbol}'. It must have a two-letter country code.\"\n                    if len(symbols) > 1:\n                        warn(message)\n                        continue\n                    raise OpenBBError(message)\n                if _transform and _transform not in helpers.QUERY_TRANSFORMS:\n                    message = f\"Invalid transformation, '{_transform}', for symbol: '{_symbol}'.\"\n                    if len(symbols) > 1:\n                        warn(message)\n                        new_symbols.append(_symbol)\n                    else:\n                        raise OpenBBError(message)\n                elif not _transform:\n                    new_symbols.append(symbol.replace(\"~\", \"\"))\n                else:\n                    new_symbols.append(symbol)\n            # Else we need to wrap each symbol with each country code\n            # and check if the country is valid for that indicator.\n            elif countries and helpers.HAS_COUNTRIES.get(symbol) is True:\n                for country in countries:\n                    _country = (\n                        helpers.INDICATOR_COUNTRIES.get(symbol, [])\n                        if country == \"all\"","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/econdb/openbb_econdb/models/economic_indicators.py#L221-L257","documentation":"OpenBBError during EconDB indicator symbol processing: a symbol like 'CPI~' or 'CPI~xyz' contains '~', the root (e.g. 'CPI') is a multi-country indicator (HAS_COUNTRIES[root] is True), but no two-letter country code was attached. When multiple symbols were requested this degrades to a warning and the symbol is skipped; with a single symbol it raises.","triggerScenarios":"Calling obb.economy.indicator(provider='econdb', symbol='CPI~') or symbol='GDP' style bare roots that require countries (via the '~' path), without using the country parameter and without appending a country code (correct form: 'CPI~us' or 'CPI_us').","commonSituations":"Misunderstanding the '~transform'/'_country' suffix grammar; passing a country-required indicator while relying on a country parameter that was omitted or invalid; batch requests where one malformed root silently disappears (warning only).","solutions":["Append a two-letter country code to the root: 'CPI~us' (transform only) or 'CPI_us' (country form).","Alternatively pass country='us' as a query parameter and keep the bare root.","In multi-symbol batches, scan warnings — malformed symbols are skipped with this same message, shrinking your result set silently."],"exampleFix":"# before\nres = obb.economy.indicator(provider=\"econdb\", symbol=\"cpi~\")\n\n# after\nres = obb.economy.indicator(provider=\"econdb\", symbol=\"cpi~us\")\n# or\nres = obb.economy.indicator(provider=\"econdb\", symbol=\"cpi\", country=\"us\")","handlingStrategy":"validation","validationCode":"from openbb_econdb.utils import helpers\n\ndef symbol_has_country_code(symbol: str) -> bool:\n    if \"~\" not in symbol:\n        return True  # different code path\n    root = symbol.split(\"~\")[0]\n    return not (helpers.HAS_COUNTRIES.get(root) is True and root in helpers.SYMBOL_TO_INDICATOR.values() and not symbol.split(\"~\")[1])","typeGuard":null,"tryCatchPattern":"from openbb_core.provider.utils.errors import OpenBBError\ntry:\n    res = obb.economy.indicator(provider=\"econdb\", symbol=s, country=cs)\nexcept OpenBBError as e:\n    if \"two-letter country code\" in str(e):\n        res = obb.economy.indicator(provider=\"econdb\", symbol=f\"{s}~us\")\n    else:\n        raise","preventionTips":["Learn the grammar: 'ROOT~transform', 'ROOT_country', or bare root + country param.","For country-required indicators always attach a 2-letter code or the country parameter.","In batches, scan warnings — malformed symbols are silently skipped."],"tags":["econdb","validation","symbols","country-codes"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}