OpenBB-finance/OpenBB · error · OpenBBError

'all' is not a supported choice for {category}. Please choos

Error message

'all' is not a supported choice for {category}. Please choose from: {list(tables)}

What it means

Raised by the EIA Weekly Petroleum Status Report fetcher's query-param validator when table='all' is requested for category='weekly_estimates'. The 'all' expansion only makes sense for the table-based categories; for weekly_estimates you must pick specific tables (e.g. 'stocks'), and the error lists the valid ones from WpsrTableMap.

Source

Thrown at openbb_platform/providers/eia/openbb_us_eia/models/petroleum_status_report.py:91

    require_credentials = False

    @staticmethod
    def transform_query(params: dict[str, Any]) -> EiaPetroleumStatusReportQueryParams:
        """Transform the query parameters."""
        # pylint: disable=import-outside-toplevel
        from warnings import warn

        category = params.get("category", "balance_sheet")
        tables = WpsrTableMap.get(category, {})
        _table = params.get("table", "")

        if not _table:
            _table = "stocks" if category == "weekly_estimates" else "all"

        _tables = _table.split(",")

        if len(_tables) == 1 and _tables[0] == "all" and category == "weekly_estimates":
            raise OpenBBError(
                ValueError(
                    f"'all' is not a supported choice for {category}. Please choose from: {list(tables)}"
                )
            )

        if "all" in _tables and len(_tables) > 1:
            _tables.remove("all")
            warn("'all' cannot be used with other table choices. Ignoring 'all'.")

        for table in _tables:
            if table != "all" and table not in tables:
                raise OpenBBError(
                    ValueError(
                        f"Invalid table choice: {table}. Valid choices for {category}: {list(tables)}"
                    )
                )

        params["table"] = ",".join(_tables)

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Set an explicit table for weekly_estimates, e.g. table='stocks' (the intended default).
  2. Pick from the list printed in the error message / WpsrTableMap['weekly_estimates'] keys.
  3. Condition your request builder: use 'all' only for categories other than weekly_estimates.

Example fix

# before
params = {'category': 'weekly_estimates', 'table': 'all'}

# after
params = {'category': 'weekly_estimates', 'table': 'stocks'}
Defensive patterns

Strategy: validation

Validate before calling

def wpsr_table_param(category: str, table: str | None) -> str:
    if category == 'weekly_estimates':
        return table or 'stocks'  # 'all' forbidden here
    return table or 'all'

Try / catch

try:
    res = await obb.energy.petroleum_status_report(category=cat, table=tbl, provider='eia')
except OpenBBError as e:
    if "'all' is not a supported choice" in str(e):
        tbl = 'stocks'
        res = await obb.energy.petroleum_status_report(category=cat, table=tbl, provider='eia')
    else:
        raise

Prevention

When it happens

Trigger: Calling the WPSR endpoint with category='weekly_estimates' and table omitted (which defaults to 'all' only for other categories) or table='all' explicitly.

Common situations: Copy-pasting a table='all' parameter across categories; assuming 'all' is a universal wildcard; upgrading code where weekly_estimates previously tolerated 'all'.

Related errors


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