OpenBB-finance/OpenBB · error · OpenBBError

'limit' cannot be set to 0 without 'bill_type' and 'congress

Error message

'limit' cannot be set to 0 without 'bill_type' and 'congress'.

What it means

OpenBBError from the same bills validator: limit=0 is the 'fetch all bills of a type' sentinel and requires bill_type to be set (and, per the fetcher, a congress). limit=0 with bill_type=None is rejected at validation time because there is no enumerable target.

Source

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

    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",
        "bill_number": "number",
        "bill_url": "url",
    }

    model_config = ConfigDict(
        json_schema_extra={

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Pair limit=0 with bill_type (and congress at fetch time), e.g. bills(congress=119, bill_type='hr', limit=0).
  2. Or set a positive limit for a normal paged listing.

Example fix

# before
obb.congress.bills(limit=0)

# after
obb.congress.bills(congress=119, bill_type='hr', limit=0)
Defensive patterns

Strategy: validation

Validate before calling

if limit == 0:
    assert bill_type is not None, 'limit=0 requires bill_type (and congress in the fetcher)'

Prevention

When it happens

Trigger: Calling obb.congress.bills(limit=0) alone; UIs sending 0 as their numeric default; removing bill_type from a copied call while keeping limit=0.

Common situations: Treating 0 as 'no limit'; form defaults of 0; misunderstandings of the sentinel convention.

Related errors


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