OpenBB-finance/OpenBB · error · OpenBBError
Category '{category}' not found. Choose from {list(SURVEY_CA
Error message
Category '{category}' not found. Choose from {list(SURVEY_CATEGORY_NAMES)} What it means
Raised by the BLS maintenance function update_survey_files (documented as 'do not use unless the static files require updating') when the category argument is not a key in SURVEY_CATEGORY_NAMES. It guards the asset-regeneration entry point against invalid category names before any download occurs. This is an input-validation OpenBBError intended for maintainers, not end users.
Source
Thrown at openbb_platform/providers/bls/openbb_bls/utils/helpers.py:412
how="all", axis=1
)
async def update_static_asset(category: str) -> None:
"""Update a static file assets with series IDs and code maps for a given category.
Do not use unless the static files in the assets folder require updating.
"""
# pylint: disable=import-outside-toplevel
import json # noqa
from importlib.resources import files
from pathlib import Path
from openbb_core.app.model.abstract.error import OpenBBError
from openbb_bls.utils.constants import SURVEY_CATEGORY_NAMES
from numpy import nan
from pandas import DataFrame
if category not in SURVEY_CATEGORY_NAMES:
raise OpenBBError(
f"Category '{category}' not found. Choose from {list(SURVEY_CATEGORY_NAMES)}"
)
try:
ids, codes = await download_category_series_ids(category)
except Exception as e: # pylint: disable=broad-except
raise OpenBBError(f"Failed to download {category} -> {e}") from e
assets_path = Path(str(files("openbb_bls").joinpath("assets")))
# Save the code map to a JSON file.
if codes:
with open(assets_path.joinpath(f"{category}_codes.json"), "w") as f:
json.dump(codes, f, indent=4)
# Save the series IDs to a CSV file.
if ids:
df = DataFrame(ids)View on GitHub (pinned to 3e071fcc2c)
Solutions
- Read list(SURVEY_CATEGORY_NAMES) from openbb_bls/utils/constants.py and pass an exact key
- Do not substitute keys from SURVEY_CATEGORY_MAP - verify which constant this function uses
- Update constants.py first if a new category was added
Example fix
# before
await update_survey_files('cpi') # OpenBBError if key set differs
# after
from openbb_bls.utils.constants import SURVEY_CATEGORY_NAMES
print(list(SURVEY_CATEGORY_NAMES)) # pick exact key
await update_survey_files(list(SURVEY_CATEGORY_NAMES)[0]) Defensive patterns
Strategy: validation
Validate before calling
from openbb_bls.utils.constants import SURVEY_CATEGORY_NAMES
def is_valid_category_name(cat: str) -> bool:
return cat in SURVEY_CATEGORY_NAMES Type guard
from openbb_bls.utils.constants import SURVEY_CATEGORY_NAMES
def is_valid_category_name(cat: str) -> bool:
return cat in SURVEY_CATEGORY_NAMES Prevention
- Note this function keys on SURVEY_CATEGORY_NAMES, not SURVEY_CATEGORY_MAP
- Print the constant's keys before running maintenance scripts
When it happens
Trigger: Calling update_survey_files('oes') when the constant keys are long-form names or different slugs; using a SURVEY_CATEGORY_MAP key where SURVEY_CATEGORY_NAMES keys are expected (the two constants have different key sets).
Common situations: Maintainers running asset regeneration after renaming categories in constants.py; passing an abbreviation that exists in one constant dict but not the other.
Related errors
- Category {category} is not a supported choice. Choose from {
- No results found for the provided query.
- Asset '{asset}' not supported. Expected .json or .xz file.
- Failed to download {category} -> {e}
- At least one extension type must be selected.
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/284f77701ddb6bc3.
Report an issue: GitHub.