OpenBB-finance/OpenBB · error · ValueError

Year must be from 1959.

Error message

Year must be from 1959.

What it means

ValueError from the FOMC document utility: a year filter was supplied that is below 1959, the first year for which the historical FOMC document archive has records. It fires before any document loading, so it is purely input validation against the dataset's known coverage.

Source

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

    Returns
    -------
    list[dict]
        A list of dictionaries mapping FOMC documents to URLs.
        Each dictionary contains the following:
        - 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

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Use year >= 1959, or omit year to get all documents.
  2. Clamp user-supplied years: year = max(year, 1959) if a default is acceptable.
  3. Validate the year range in your UI/config before calling.

Example fix

// before
get_fomc_documents(year=1945)
// after
get_fomc_documents(year=max(1945, 1959))  # or omit year
Defensive patterns

Strategy: validation

Validate before calling

year = int(year) if isinstance(year, str) else year
if year is not None and year < 1959:
    raise ValueError('FOMC documents start at 1959')  # fail early with your own message

Type guard

def is_valid_fomc_year(y) -> bool:
    try:
        return 1959 <= int(str(y).strip()) <= 2100
    except ValueError:
        return False

Prevention

When it happens

Trigger: Calling the FOMC documents helper with year=1958 or earlier (including year passed as a string like '1950', which still compares < 1959 after truthiness check ordering — note the string comparison quirk in the source).

Common situations: Historical research scripts looping over decades; passing 0 or placeholder values; off-by-one when computing year ranges.

Related errors


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