OpenBB-finance/OpenBB · error · ValueError
Country '{v.name}' ({v.alpha_2}) is not supported by FMP. Va
Error message
Country '{v.name}' ({v.alpha_2}) is not supported by FMP. Valid options: {', '.join(sorted(valid_countries)[:20])}... What it means
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.
Source
Thrown at openbb_platform/providers/fmp/openbb_fmp/models/equity_screener.py:175
@classmethod
def _validate_industry(cls, v):
"""Validate industry."""
industries = [v["value"] for v in IndustryChoices]
if v and v not in industries + ["all"]:
raise ValueError(f"Industry must be one of {', '.join(industries)}")
return v
@field_validator("country", mode="after")
@classmethod
def _validate_country(cls, v):
"""Validate country is supported by FMP."""
if v is None:
return v
# Country stores alpha_2 in uppercase, FMP expects lowercase
country_code = v.alpha_2.lower()
valid_countries = list(Countries.__args__)
if country_code not in valid_countries:
raise ValueError(
f"Country '{v.name}' ({v.alpha_2}) is not supported by FMP. "
f"Valid options: {', '.join(sorted(valid_countries)[:20])}..."
)
return v
@field_validator("exchange", mode="after")
@classmethod
def _validate_exchange(cls, v):
"""Validate exchange is supported by FMP."""
if v is None:
return v
# Exchange stores MIC, FMP expects lowercase acronym
exchange_code = v.acronym.lower()
valid_exchanges = list(Exchanges.__args__)
if exchange_code not in valid_exchanges:
raise ValueError(
f"Exchange '{v.name}' ({v.mic}) is not supported by FMP. "
f"Valid options: {', '.join(sorted(valid_exchanges)[:20])}..."View on GitHub (pinned to 3e071fcc2c)
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
Example fix
# before res = obb.screener.equity(provider='fmp', country='Vatican City') # alpha_2 'VA' not supported # after res = obb.screener.equity(provider='fmp', country='IT') # supported # or filter client-side all_res = obb.screener.equity(provider='fmp') va_stocks = [r for r in all_res.results if r.country == 'VA']
Defensive patterns
Strategy: validation
Validate before calling
from openbb_fmp.utils.references import Countries
VALID_COUNTRIES = set(Countries.__args__)
import pycountry
c = pycountry.countries.get(alpha_2='VA')
if c and c.alpha_2.lower() not in VALID_COUNTRIES:
country = None # drop unsupported filter Type guard
def is_supported_fmp_country(alpha_2: str) -> bool:
from openbb_fmp.utils.references import Countries
return alpha_2.lower() in Countries.__args__ Try / catch
from pydantic import ValidationError
try:
res = obb.screener.equity(provider='fmp', country=cc)
except ValidationError:
res = obb.screener.equity(provider='fmp') # no country filter; filter rows client-side Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Exchange '{v.name}' ({v.mic}) is not supported by FMP. Valid
- Industry must be one of {', '.join(industries)}
- Invalid country: '{value}'. Accepts ISO 3166-1 alpha-2 codes
- No valid combination of indicator symbols and countries were
- Invalid signal '{v}'. Available signals are: {SIGNALS_DESC_S
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/c35b777c72bd66ab.
Report an issue: GitHub.