OpenBB-finance/OpenBB · error · OpenBBError

Invalid bill_type: {values.bill_type}. Must be one of: {', '

Error message

Invalid bill_type: {values.bill_type}. Must be one of: {', '.join(BillTypes)}.

What it means

OpenBBError from the CongressBillsQueryParams validator: bill_type, when supplied, must be one of the BillTypes codes ('hr', 's', 'hjres', 'sjres', 'hconres', 'sconres', 'hres', 'sres'). Raised during parameter validation before any request, with the full allowed list in the message.

Source

Thrown at openbb_platform/providers/congress_gov/openbb_congress_gov/models/congress_bills.py:92

        default=None,
        description=QUERY_DESCRIPTIONS.get("limit", "")
        + " When None, default sets to 100 (max 250)."
        + " Set to 0 for no limit (must be used with 'bill_type' and 'congress')."
        + " Setting to 0 will nullify the start_date, end_date, and offset parameters.",
    )
    offset: int | None = Field(
        default=None, description="The starting record returned. 0 is the first record."
    )
    sort_by: Literal["asc", "desc"] = Field(
        default="desc", description="Sort by update date. Default is latest first."
    )

    @model_validator(mode="after")
    @classmethod
    def validate_query(cls, values):
        """Validate the query parameters."""
        if values.bill_type is not None and values.bill_type not in BillTypes:
            raise OpenBBError(
                ValueError(
                    f"Invalid bill_type: {values.bill_type}. Must be one of: {', '.join(BillTypes)}."
                )
            )
        if values.limit == 0 and values.bill_type is None:
            raise OpenBBError(
                ValueError(
                    "'limit' cannot be set to 0 without 'bill_type' and 'congress'."
                )
            )
        return values


class CongressBillsData(Data):
    """Congress Bills Data."""

    __alias_dict__ = {
        "bill_type": "type",

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Use the lowercase Thomson-style code from the message, e.g. 'hr' or 's'.
  2. Lowercase/strip input before passing: bill_type = bill_type.strip().lower().
  3. Constrain UI fields to the eight valid codes.

Example fix

# before
obb.congress.bills(bill_type='House Resolution')

# after
obb.congress.bills(bill_type='hres')
Defensive patterns

Strategy: type-guard

Validate before calling

BILL_TYPES = {'hr','s','hjres','sjres','hconres','sconres','hres','sres'}
if bill_type is not None:
    assert bill_type.strip().lower() in BILL_TYPES, f'use one of {sorted(BILL_TYPES)}'

Type guard

from typing import Literal
BillType = Literal['hr','s','hjres','sjres','hconres','sconres','hres','sres']

def is_bill_type(v: str) -> bool:
    return v in ('hr','s','hjres','sjres','hconres','sconres','hres','sres')

Prevention

When it happens

Trigger: Calling obb.congress.bills(bill_type='house') or 'HR' (uppercase); passing the long title 'House Resolution' from a form; forwarding free-text user input.

Common situations: Case sensitivity ('HR' vs 'hr'); chamber names used instead of bill-type codes; autocomplete fields without constrained vocabularies.

Related errors


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