{"record":{"id":"9bf2b79b1364b418","repo":"OpenBB-finance/OpenBB","slug":"invalid-table-choice-table-valid-choices-for","errorCode":null,"errorMessage":"Invalid table choice: {table}. Valid choices for {category}: {list(tables)}","messagePattern":"Invalid table choice: (.+?)\\. Valid choices for (.+?): (.+?)","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/eia/openbb_us_eia/models/petroleum_status_report.py","lineNumber":103,"sourceCode":"        if not _table:\n            _table = \"stocks\" if category == \"weekly_estimates\" else \"all\"\n\n        _tables = _table.split(\",\")\n\n        if len(_tables) == 1 and _tables[0] == \"all\" and category == \"weekly_estimates\":\n            raise OpenBBError(\n                ValueError(\n                    f\"'all' is not a supported choice for {category}. Please choose from: {list(tables)}\"\n                )\n            )\n\n        if \"all\" in _tables and len(_tables) > 1:\n            _tables.remove(\"all\")\n            warn(\"'all' cannot be used with other table choices. Ignoring 'all'.\")\n\n        for table in _tables:\n            if table != \"all\" and table not in tables:\n                raise OpenBBError(\n                    ValueError(\n                        f\"Invalid table choice: {table}. Valid choices for {category}: {list(tables)}\"\n                    )\n                )\n\n        params[\"table\"] = \",\".join(_tables)\n\n        return EiaPetroleumStatusReportQueryParams(**params)\n\n    @staticmethod\n    async def aextract_data(\n        query: EiaPetroleumStatusReportQueryParams,\n        credentials: dict[str, Any] | None,\n        **kwargs: Any,\n    ) -> dict:\n        \"\"\"Extract the data from the EIA website.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        from openbb_us_eia.utils.helpers import download_excel_file","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/eia/openbb_us_eia/models/petroleum_status_report.py#L85-L121","documentation":"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.","triggerScenarios":"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.","commonSituations":"Hard-coded table names breaking when WpsrTableMap is updated; case mismatch ('Stocks' vs 'stocks'); copying example params from docs for a different category.","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."],"exampleFix":"# before\nparams = {'category': 'weekly_estimates', 'table': 'inventory'}\n\n# after\nfrom openbb_us_eia.utils.helpers import WpsrTableMap\nvalid = list(WpsrTableMap['weekly_estimates'])\nparams = {'category': 'weekly_estimates', 'table': valid[0]}","handlingStrategy":"validation","validationCode":"from openbb_us_eia.utils.helpers import WpsrTableMap\n\ndef valid_tables(category: str, tables: list[str]) -> bool:\n    allowed = set(WpsrTableMap.get(category, {})) | {'all'}\n    return all(t in allowed for t in tables)","typeGuard":null,"tryCatchPattern":"try:\n    res = await obb.energy.petroleum_status_report(category=cat, table=','.join(tbls), provider='eia')\nexcept OpenBBError as e:\n    if 'Invalid table choice' in str(e):\n        # parse the valid list from the message or re-derive and fix\n        tbls = [t for t in tbls if t in WpsrTableMap.get(cat, {})]\n        res = await obb.energy.petroleum_status_report(category=cat, table=','.join(tbls), provider='eia')\n    else:\n        raise","preventionTips":["Derive table names from WpsrTableMap, not docs or memory","Scope table choices to the selected category in UIs"],"tags":["eia","petroleum-status-report","validation","parameter-choices"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}