OpenBB-finance/OpenBB · error · OpenBBError
Invalid table choice: {table}. Valid choices for {category}:
Error message
Invalid table choice: {table}. Valid choices for {category}: {list(tables)} What it means
EIA Weekly Petroleum Status Report validator: each comma-separated table name in the table parameter must be a key of WpsrTableMap for the chosen category (or the literal 'all'). An unknown name raises this OpenBBError listing the valid choices for that category.
Source
Thrown at openbb_platform/providers/eia/openbb_us_eia/models/petroleum_status_report.py:103
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)
return EiaPetroleumStatusReportQueryParams(**params)
@staticmethod
async def aextract_data(
query: EiaPetroleumStatusReportQueryParams,
credentials: dict[str, Any] | None,
**kwargs: Any,
) -> dict:
"""Extract the data from the EIA website."""
# pylint: disable=import-outside-toplevel
from openbb_us_eia.utils.helpers import download_excel_fileView on GitHub (pinned to 3e071fcc2c)
Solutions
- Use a table name from the error message's valid list (keys of WpsrTableMap[category]).
- Match the category and table pair — tables are per-category, not global.
- Reference openbb_us_eia.utils.helpers.WpsrTableMap at runtime to build dynamic UI choices instead of hard-coding.
- Check spelling and case exactly.
Example fix
# before
params = {'category': 'weekly_estimates', 'table': 'inventory'}
# after
from openbb_us_eia.utils.helpers import WpsrTableMap
valid = list(WpsrTableMap['weekly_estimates'])
params = {'category': 'weekly_estimates', 'table': valid[0]} Defensive patterns
Strategy: validation
Validate before calling
from openbb_us_eia.utils.helpers import WpsrTableMap
def valid_tables(category: str, tables: list[str]) -> bool:
allowed = set(WpsrTableMap.get(category, {})) | {'all'}
return all(t in allowed for t in tables) Try / catch
try:
res = await obb.energy.petroleum_status_report(category=cat, table=','.join(tbls), provider='eia')
except OpenBBError as e:
if 'Invalid table choice' in str(e):
# parse the valid list from the message or re-derive and fix
tbls = [t for t in tbls if t in WpsrTableMap.get(cat, {})]
res = await obb.energy.petroleum_status_report(category=cat, table=','.join(tbls), provider='eia')
else:
raise Prevention
- Derive table names from WpsrTableMap, not docs or memory
- Scope table choices to the selected category in UIs
When it happens
Trigger: Passing table='inventories' when the category's map has no such key; mixing table names from one category with another category (e.g. a 'balance_sheet' table name while category='weekly_estimates'); typos or renamed tables after a provider update.
Common situations: Hard-coded table names breaking when WpsrTableMap is updated; case mismatch ('Stocks' vs 'stocks'); copying example params from docs for a different category.
Related errors
- 'all' is not a supported choice for {category}. Please choos
- Error extracting data -> {e}
- Expected an ExcelFile object, got {type(file)} instead.
- The data is empty.
- Error transforming the data -> {e}
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/9bf2b79b1364b418.
Report an issue: GitHub.