OpenBB-finance/OpenBB · error · ValueError

Invalid country: {v}. Available countries are: {', '.join(CP

Error message

Invalid country: {v}. Available countries are: {', '.join(CPI_COUNTRIES)}

What it means

Error "Invalid country: {v}. Available countries are: {', '.join(CPI_COUNTRIES)}" thrown in OpenBB-finance/OpenBB.

Source

Thrown at openbb_platform/providers/fred/openbb_fred/models/consumer_price_index.py:40

    __json_schema_extra__ = {
        "country": {
            "multiple_items_allowed": True,
            "choices": CPI_COUNTRIES,
        },
        "transform": {
            "choices": ["index", "yoy", "period"],
        },
    }

    @field_validator("country", mode="before", check_fields=False)
    @classmethod
    def validate_country(cls, c: str):
        """Validate country."""
        result: list = []
        values = c.replace(" ", "_").split(",")
        for v in values:
            if v.lower() not in CPI_COUNTRIES:
                raise ValueError(
                    f"Invalid country: {v}. Available countries are: {', '.join(CPI_COUNTRIES)}"
                )
            result.append(v.lower())
        return ",".join(result)

    @field_validator("transform", mode="before", check_fields=False)
    @classmethod
    def validate_transform(cls, t: str):
        """Validate transform."""
        valid_transforms = ["index", "yoy", "period"]
        if t.lower() not in valid_transforms:
            raise ValueError(
                f"Invalid transform: {t}. Available transforms are: {', '.join(valid_transforms)}"
            )
        return t.lower()


class FREDConsumerPriceIndexData(ConsumerPriceIndexData):

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Choose a country from the listed available CPI countries.
  2. Pass the country exactly as listed (correct spelling and case).

When it happens

Trigger: Thrown at openbb_platform/providers/fred/openbb_fred/models/consumer_price_index.py:40 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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