OpenBB-finance/OpenBB · error · ValueError

Expenditure '{e}' is not a valid choice. Valid choices: {ex

Error message

Expenditure '{e}' is not a valid choice. Valid choices:

{expenditure_choices}

What it means

Error "Expenditure '{e}' is not a valid choice. Valid choices: {expenditure_choices}" thrown in OpenBB-finance/OpenBB.

Source

Thrown at openbb_platform/providers/imf/openbb_imf/models/consumer_price_index.py:370

            else:
                raise ValueError(
                    f"Country '{v}' is not a valid IMF country code (ISO3) or country name."
                )

        return ",".join(result)

    @field_validator("expenditure", mode="before", check_fields=False)
    @classmethod
    def validate_expenditure(cls, v):
        """Validate expenditure."""
        expenditures = v.replace(" ", "_").split(",")
        new_expenditures: list[str] = []
        for e in expenditures:
            if (
                e.lower() not in expenditure_choices
                and e.upper() not in expenditure_dict_rev
            ):
                raise ValueError(
                    f"Expenditure '{e}' is not a valid choice. Valid choices:\n\n{expenditure_choices}"
                )
            new_expenditures.append(e.lower())
        return ",".join(new_expenditures)


class ImfConsumerPriceIndexData(ConsumerPriceIndexData):
    """IMF CPI Data Model."""

    unit: str = Field(
        description="Unit of measurement.",
    )
    unit_multiplier: int | float = Field(
        description="Unit multiplier for the observation value.",
    )
    country_code: str = Field(
        description="ISO3 country code.",
    )

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Choose an expenditure from the listed valid choices.
  2. Omit the expenditure parameter to use the default.

When it happens

Trigger: Thrown at openbb_platform/providers/imf/openbb_imf/models/consumer_price_index.py:370 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/a5f1fa99a1456604. Report an issue: GitHub.