OpenBB-finance/OpenBB · error · ValueError

Year must be an integer.

Error message

Year must be an integer.

What it means

ValueError from the same FOMC utility: year arrived as a string whose isdigit() check failed, so it was coerced to 0 and rejected. The utility accepts string years but only all-digit strings — anything with a sign, whitespace, decimal point, or letters becomes 0.

Source

Thrown at openbb_platform/providers/federal_reserve/openbb_federal_reserve/utils/fomc_documents.py:188

        - date: str
            The date of the document, formatted as YYYY-MM-DD.
        - doc_type: str
            The type of the document.
        - doc_format: str
            The format of the document.
        - url: str
            The URL of the document
    """
    filtered_docs: list[dict] = []
    choice_types = list(getattr(FomcDocumentType, "__args__", ()))

    if year and year < 1959:
        raise ValueError("Year must be from 1959.")

    if year and isinstance(year, str):
        year = int(year) if year.isdigit() else 0
        if year == 0:
            raise ValueError("Year must be an integer.")

    if not document_type:
        document_type = "all"

    if document_type not in choice_types:
        raise ValueError(
            f"Invalid document type. Must be one of: {', '.join(choice_types)}"
        )

    if year:
        docs = (
            get_current_fomc_documents()
            if year > 2024
            else load_historical_fomc_documents()
        )
    else:
        current_docs = get_current_fomc_documents()
        historical_docs = load_historical_fomc_documents()

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Normalize before calling: strip whitespace and convert with int(year_str) inside your own try/except.
  2. Pass an int when possible — the utility accepts both.
  3. Reject non-numeric input client-side with a clear message.

Example fix

// before
get_fomc_documents(year=' 1995')
// after
get_fomc_documents(year=int(' 1995'.strip()))
Defensive patterns

Strategy: validation

Validate before calling

year = int(str(year).strip())  # raises a clear ValueError here instead of inside the util

Type guard

def is_digit_year(s) -> bool:
    return isinstance(s, str) and s.strip().isdigit()

Prevention

When it happens

Trigger: Passing year='19_95', year=' 1995', year='1995.0', year='-1995', or year='FY1995' — any non-pure-digit string. Note this check runs after the 'year < 1959' comparison, so some malformed strings fail earlier instead.

Common situations: Web form or CLI input that forwards raw strings; years extracted from filenames or free text without normalization; locale-specific digit formats.

Related errors


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