{"record":{"id":"c35b777c72bd66ab","repo":"OpenBB-finance/OpenBB","slug":"country-v-name-v-alpha-2-is-not-supported","errorCode":null,"errorMessage":"Country '{v.name}' ({v.alpha_2}) is not supported by FMP. Valid options: {', '.join(sorted(valid_countries)[:20])}...","messagePattern":"Country '(.+?)' \\((.+?)\\) is not supported by FMP\\. Valid options: (.+?)\\.\\.\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/fmp/openbb_fmp/models/equity_screener.py","lineNumber":175,"sourceCode":"    @classmethod\n    def _validate_industry(cls, v):\n        \"\"\"Validate industry.\"\"\"\n        industries = [v[\"value\"] for v in IndustryChoices]\n        if v and v not in industries + [\"all\"]:\n            raise ValueError(f\"Industry must be one of {', '.join(industries)}\")\n        return v\n\n    @field_validator(\"country\", mode=\"after\")\n    @classmethod\n    def _validate_country(cls, v):\n        \"\"\"Validate country is supported by FMP.\"\"\"\n        if v is None:\n            return v\n        # Country stores alpha_2 in uppercase, FMP expects lowercase\n        country_code = v.alpha_2.lower()\n        valid_countries = list(Countries.__args__)\n        if country_code not in valid_countries:\n            raise ValueError(\n                f\"Country '{v.name}' ({v.alpha_2}) is not supported by FMP. \"\n                f\"Valid options: {', '.join(sorted(valid_countries)[:20])}...\"\n            )\n        return v\n\n    @field_validator(\"exchange\", mode=\"after\")\n    @classmethod\n    def _validate_exchange(cls, v):\n        \"\"\"Validate exchange is supported by FMP.\"\"\"\n        if v is None:\n            return v\n        # Exchange stores MIC, FMP expects lowercase acronym\n        exchange_code = v.acronym.lower()\n        valid_exchanges = list(Exchanges.__args__)\n        if exchange_code not in valid_exchanges:\n            raise ValueError(\n                f\"Exchange '{v.name}' ({v.mic}) is not supported by FMP. \"\n                f\"Valid options: {', '.join(sorted(valid_exchanges)[:20])}...\"","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/fmp/openbb_fmp/models/equity_screener.py#L157-L193","documentation":"A Pydantic field_validator ValueError on FMPEquityScreenerQueryParams.country: the Country object is converted to its lowercase alpha-2 code and checked against the FMP-supported set (the Countries Literal). Unsupported countries are rejected client-side with a message listing the first 20 valid codes.","triggerScenarios":"Calling obb.equity.screener(provider='fmp', country=...) with a pycountry Country that FMP does not cover - small/exotic markets (e.g. certain African or island nations) whose alpha-2 code is absent from the Countries literal.","commonSituations":"Screening global universes where some markets have no FMP coverage, passing a full country object/name where the validator expects something pycountry-constructible, or the FMP-supported list shrinking/changing across provider versions.","solutions":["Pick a supported country from the error message (first 20 shown) or from the Countries Literal in openbb_fmp.utils.references","Drop the country filter and filter results by country client-side if your target market is unsupported","Catch the pydantic ValidationError and present the valid country list to the user"],"exampleFix":"# before\nres = obb.screener.equity(provider='fmp', country='Vatican City')  # alpha_2 'VA' not supported\n\n# after\nres = obb.screener.equity(provider='fmp', country='IT')            # supported\n# or filter client-side\nall_res = obb.screener.equity(provider='fmp')\nva_stocks = [r for r in all_res.results if r.country == 'VA']","handlingStrategy":"validation","validationCode":"from openbb_fmp.utils.references import Countries\nVALID_COUNTRIES = set(Countries.__args__)\nimport pycountry\nc = pycountry.countries.get(alpha_2='VA')\nif c and c.alpha_2.lower() not in VALID_COUNTRIES:\n    country = None  # drop unsupported filter","typeGuard":"def is_supported_fmp_country(alpha_2: str) -> bool:\n    from openbb_fmp.utils.references import Countries\n    return alpha_2.lower() in Countries.__args__","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    res = obb.screener.equity(provider='fmp', country=cc)\nexcept ValidationError:\n    res = obb.screener.equity(provider='fmp')  # no country filter; filter rows client-side","preventionTips":["Build country dropdowns from the FMP Countries literal, not pycountry's full list","Re-check supported markets after provider upgrades","Fall back to client-side filtering for unsupported markets"],"tags":["fmp","validation","screener","country","coverage"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}