{"record":{"id":"284f77701ddb6bc3","repo":"OpenBB-finance/OpenBB","slug":"category-category-not-found-choose-from-list","errorCode":null,"errorMessage":"Category '{category}' not found. Choose from {list(SURVEY_CATEGORY_NAMES)}","messagePattern":"Category '(.+?)' not found\\. Choose from (.+?)","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/bls/openbb_bls/utils/helpers.py","lineNumber":412,"sourceCode":"            how=\"all\", axis=1\n        )\n\n\nasync def update_static_asset(category: str) -> None:\n    \"\"\"Update a static file assets with series IDs and code maps for a given category.\n    Do not use unless the static files in the assets folder require updating.\n    \"\"\"\n    # pylint: disable=import-outside-toplevel\n    import json  # noqa\n    from importlib.resources import files\n    from pathlib import Path\n    from openbb_core.app.model.abstract.error import OpenBBError\n    from openbb_bls.utils.constants import SURVEY_CATEGORY_NAMES\n    from numpy import nan\n    from pandas import DataFrame\n\n    if category not in SURVEY_CATEGORY_NAMES:\n        raise OpenBBError(\n            f\"Category '{category}' not found. Choose from {list(SURVEY_CATEGORY_NAMES)}\"\n        )\n\n    try:\n        ids, codes = await download_category_series_ids(category)\n    except Exception as e:  # pylint: disable=broad-except\n        raise OpenBBError(f\"Failed to download {category} -> {e}\") from e\n\n    assets_path = Path(str(files(\"openbb_bls\").joinpath(\"assets\")))\n\n    # Save the code map to a JSON file.\n    if codes:\n        with open(assets_path.joinpath(f\"{category}_codes.json\"), \"w\") as f:\n            json.dump(codes, f, indent=4)\n\n    # Save the series IDs to a CSV file.\n    if ids:\n        df = DataFrame(ids)","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/bls/openbb_bls/utils/helpers.py#L394-L430","documentation":"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.","triggerScenarios":"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).","commonSituations":"Maintainers running asset regeneration after renaming categories in constants.py; passing an abbreviation that exists in one constant dict but not the other.","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"],"exampleFix":"# before\nawait update_survey_files('cpi')  # OpenBBError if key set differs\n\n# after\nfrom openbb_bls.utils.constants import SURVEY_CATEGORY_NAMES\nprint(list(SURVEY_CATEGORY_NAMES))  # pick exact key\nawait update_survey_files(list(SURVEY_CATEGORY_NAMES)[0])","handlingStrategy":"validation","validationCode":"from openbb_bls.utils.constants import SURVEY_CATEGORY_NAMES\n\ndef is_valid_category_name(cat: str) -> bool:\n    return cat in SURVEY_CATEGORY_NAMES","typeGuard":"from openbb_bls.utils.constants import SURVEY_CATEGORY_NAMES\n\ndef is_valid_category_name(cat: str) -> bool:\n    return cat in SURVEY_CATEGORY_NAMES","tryCatchPattern":null,"preventionTips":["Note this function keys on SURVEY_CATEGORY_NAMES, not SURVEY_CATEGORY_MAP","Print the constant's keys before running maintenance scripts"],"tags":["bls","maintenance","validation","constants"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}