OpenBB-finance/OpenBB · error · OpenBBError

No valid countries were supplied.

Error message

No valid countries were supplied.

What it means

Same 'No valid countries were supplied' validation as in country_profile, but inside EconDbEconomicIndicatorsQueryParams' country validator: every supplied token failed to resolve via THREE_LETTER_ISO_MAP / COUNTRY_MAP / COUNTRY_GROUPS, warnings fired for the bad ones, and the normalized list came out empty.

Source

Thrown at openbb_platform/providers/econdb/openbb_econdb/models/economic_indicators.py:103

                    and c.upper() not in list(helpers.COUNTRY_MAP.values())
                    and c.lower() != "g7"
                ):
                    country.remove(c)
                elif len(c) == 3 and c.lower() != "g20":
                    _c = helpers.THREE_LETTER_ISO_MAP.get(c.upper(), "")
                    if _c:
                        country[country.index(c)] = _c
                    else:
                        warn(f"Error: {c} is not a valid country code.")
                        country.remove(c)
                elif len(c) > 3 and c.lower() in helpers.COUNTRY_MAP:
                    country[country.index(c)] = helpers.COUNTRY_MAP[c.lower()].upper()
                elif len(c) > 2 and c.lower() in helpers.COUNTRY_GROUPS:
                    country[country.index(c)] = ",".join(
                        helpers.COUNTRY_GROUPS[c.lower()]
                    )
            if len(country) == 0:
                raise OpenBBError("No valid countries were supplied.")
            return ",".join(country)
        return None

    @field_validator("symbol", mode="before", check_fields=False)
    @classmethod
    def validate_symbols(cls, v):
        """Validate each symbol to check if it is a valid indicator."""
        # pylint: disable=import-outside-toplevel
        from openbb_econdb.utils import helpers

        INDICATORS = list(helpers.INDICATORS_DESCRIPTIONS)
        if not v:
            v = "main"
        symbols = v if isinstance(v, list) else v.split(",")
        new_symbols: list[str] = []
        for symbol in symbols:
            if "_" in symbol:
                new_symbols.append(symbol)

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Use ISO alpha-2 ('us') or alpha-3 ('usa') codes, or group names in COUNTRY_GROUPS (e.g. 'g20').
  2. Read the preceding warnings to see exactly which codes were dropped.
  3. Pre-validate with openbb_econdb.utils.helpers.THREE_LETTER_ISO_MAP / COUNTRY_MAP before building the query.
  4. Omit country entirely for indicators where you'll specify the country inline in the symbol (e.g. ' CPI~us').

Example fix

# before
res = obb.economy.indicator(provider="econdb", country="xx", symbol="cpi")

# after
res = obb.economy.indicator(provider="econdb", country="us", symbol="cpi")
Defensive patterns

Strategy: validation

Validate before calling

from openbb_econdb.utils.helpers import THREE_LETTER_ISO_MAP, COUNTRY_MAP, COUNTRY_GROUPS

def valid_country_tokens(tokens: list[str]) -> list[str]:
    ok = []
    for t in tokens:
        k = t.lower()
        if (len(t) == 2) or (len(t) == 3 and THREE_LETTER_ISO_MAP.get(t.upper())) or k in COUNTRY_MAP or k in COUNTRY_GROUPS:
            ok.append(t)
    return ok  # empty list => the API call would raise

Try / catch

from openbb_core.provider.utils.errors import OpenBBError
try:
    res = obb.economy.indicator(provider="econdb", country=cs, symbol=s)
except OpenBBError as e:
    if "No valid countries" in str(e):
        cs = prompt_for_valid_codes()
        res = obb.economy.indicator(provider="econdb", country=cs, symbol=s)
    else:
        raise

Prevention

When it happens

Trigger: Calling obb.economy.indicator(provider='econdb', country=..., symbol=...) with country tokens like 'XX', 'ZZZ', or unmapped names. The validator returns only for non-None input, so this hits whenever the country parameter is provided but wholly invalid.

Common situations: Passing non-ISO or informal country strings; typo'd alpha-2 codes from user input or CSVs; assuming long names ('United States') are accepted when the map expects specific aliases.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/debcc3d6dc0d98a2. Report an issue: GitHub.