{"record":{"id":"44e34d8aa1693003","repo":"OpenBB-finance/OpenBB","slug":"dataset-dataset-not-found-in-available-datasets","errorCode":null,"errorMessage":"Dataset {dataset} not found in available datasets: {list(url_map)}","messagePattern":"Dataset (.+?) not found in available datasets: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/famafrench/openbb_famafrench/utils/helpers.py","lineNumber":166,"sourceCode":"\n@lru_cache(maxsize=64)\ndef download_file(dataset) -> str:\n    \"\"\"Download the specified dataset file from the Ken French data library.\n\n    Note: This function is not intended for direct use, it is called by `get_portfolio_data`.\n    \"\"\"\n    # pylint: disable=import-outside-toplevel\n    import zipfile\n    from io import BytesIO\n\n    from openbb_core.provider.utils.helpers import get_requests_session\n\n    url_map = {item[\"label\"]: item[\"value\"] for item in DATASET_CHOICES}\n\n    if dataset.replace(\"_\", \" \") not in list(url_map) and dataset not in list(\n        url_map.values()\n    ):\n        raise ValueError(\n            f\"Dataset {dataset} not found in available datasets: {list(url_map)}\"\n        )\n\n    url = (\n        BASE_URL + dataset\n        if dataset.endswith(\".zip\")\n        else BASE_URL + url_map[dataset.replace(\"_\", \" \")]\n    )\n\n    with get_requests_session() as session:\n        response = session.get(url)\n        response.raise_for_status()\n\n    data = \"\"\n\n    with zipfile.ZipFile(BytesIO(response.content)) as f:\n        with f.open(f.namelist()[0]) as file:  # type: ignore\n            data = file.read()  # type: ignore","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/famafrench/openbb_famafrench/utils/helpers.py#L148-L184","documentation":"Raised by famafrench download_file when the requested dataset name matches neither a label (with underscores swapped for spaces) nor a value in DATASET_CHOICES. It is a pure client-side validation error: no network call is made until the dataset resolves to a URL.","triggerScenarios":"Calling a famafrench endpoint with a dataset argument not present in DATASET_CHOICES, e.g. a typo, a label with wrong casing, or a dataset name from a newer/older provider version.","commonSituations":"Hardcoding a dataset label that was renamed between provider releases; passing the zip filename when the label form (spaces, not underscores) is expected; case-sensitive label mismatch.","solutions":["Read DATASET_CHOICES from openbb_famafrench/utils/helpers.py (or the endpoint's OpenAPI param choices) and copy an exact label.","Remember underscores are normalized to spaces before lookup, so '5_industry_portfolios' works if the label is '5 industry portfolios'.","Alternatively pass the exact .zip filename value from the choices map.","Upgrade the provider if the dataset exists upstream but not in your installed DATASET_CHOICES."],"exampleFix":"// before\nobb.economy.famafrench.us_portfolio_returns(dataset='5_industry')  # ValueError\n\n// after\nfrom openbb_famafrench.utils.helpers import DATASET_CHOICES\nlabels = [c['label'] for c in DATASET_CHOICES]\nobb.economy.famafrench.us_portfolio_returns(dataset='5_industry_portfolios')","handlingStrategy":"validation","validationCode":"from openbb_famafrench.utils.helpers import DATASET_CHOICES\nvalid = {c['label'] for c in DATASET_CHOICES} | {c['value'] for c in DATASET_CHOICES}\nassert dataset.replace('_', ' ') in valid or dataset in valid, f'bad dataset: {dataset}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Source allowed datasets from DATASET_CHOICES at runtime instead of hardcoding strings.","Remember underscore labels are normalized to spaces; raw .zip filenames also work."],"tags":["famafrench","validation","dataset-choice"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}