OpenBB-finance/OpenBB · error · ValueError

Invalid document type. Must be one of: {', '.join(choice_typ

Error message

Invalid document type. Must be one of: {', '.join(choice_types)}

What it means

ValueError raised when document_type is non-empty but not one of the FomcDocumentType Literal choices. The helper defaults empty/None to 'all', so this specifically means a wrong-typed value was supplied. The message lists the exact accepted choices.

Source

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

        - 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()
        docs = current_docs + historical_docs

    for doc in docs:
        doc_year = int(doc["date"].split("-")[0])
        if year and doc_year != year:
            continue

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Use one of the choices printed in the message, exactly as listed (case- and spelling-sensitive).
  2. Derive allowed values programmatically from FomcDocumentType's args instead of hardcoding.
  3. Lowercase/strip user input, then check membership before calling.

Example fix

from typing import get_args
from openbb_federal_reserve.utils.fomc_documents import FomcDocumentType
# before
get_fomc_documents(document_type='Minutes')
# after
choices = [str(c) for c in get_args(FomcDocumentType)]
doc_type = 'Minutes'.strip().lower()
assert doc_type in choices, f'use one of {choices}'
Defensive patterns

Strategy: validation

Validate before calling

from typing import get_args
from openbb_federal_reserve.utils.fomc_documents import FomcDocumentType
choices = [str(c) for c in get_args(FomcDocumentType)]
doc_type = (document_type or 'all').strip().lower()
assert doc_type in choices, f'document_type must be one of {choices}'

Type guard

def is_valid_doc_type(v) -> bool:
    from typing import get_args
    from openbb_federal_reserve.utils.fomc_documents import FomcDocumentType
    return (v or 'all') in [str(c) for c in get_args(FomcDocumentType)]

Prevention

When it happens

Trigger: Passing document_type='minutes ' (trailing space — no strip is applied), 'agenda' vs 'agendas', wrong case like 'Minutes', or a type added/renamed in a newer provider version than the caller was written against.

Common situations: Hardcoded strings from older OpenBB versions after FomcDocumentType gained/renamed members; user input forwarded verbatim without normalization.

Related errors


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