OpenBB-finance/OpenBB · error · ValueError
Dataset {dataset} not found in available datasets: {list(url
Error message
Dataset {dataset} not found in available datasets: {list(url_map)} What it means
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.
Source
Thrown at openbb_platform/providers/famafrench/openbb_famafrench/utils/helpers.py:166
@lru_cache(maxsize=64)
def download_file(dataset) -> str:
"""Download the specified dataset file from the Ken French data library.
Note: This function is not intended for direct use, it is called by `get_portfolio_data`.
"""
# pylint: disable=import-outside-toplevel
import zipfile
from io import BytesIO
from openbb_core.provider.utils.helpers import get_requests_session
url_map = {item["label"]: item["value"] for item in DATASET_CHOICES}
if dataset.replace("_", " ") not in list(url_map) and dataset not in list(
url_map.values()
):
raise ValueError(
f"Dataset {dataset} not found in available datasets: {list(url_map)}"
)
url = (
BASE_URL + dataset
if dataset.endswith(".zip")
else BASE_URL + url_map[dataset.replace("_", " ")]
)
with get_requests_session() as session:
response = session.get(url)
response.raise_for_status()
data = ""
with zipfile.ZipFile(BytesIO(response.content)) as f:
with f.open(f.namelist()[0]) as file: # type: ignore
data = file.read() # type: ignoreView on GitHub (pinned to 3e071fcc2c)
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.
Example fix
// before obb.economy.famafrench.us_portfolio_returns(dataset='5_industry') # ValueError // after from openbb_famafrench.utils.helpers import DATASET_CHOICES labels = [c['label'] for c in DATASET_CHOICES] obb.economy.famafrench.us_portfolio_returns(dataset='5_industry_portfolios')
Defensive patterns
Strategy: validation
Validate before calling
from openbb_famafrench.utils.helpers import DATASET_CHOICES
valid = {c['label'] for c in DATASET_CHOICES} | {c['value'] for c in DATASET_CHOICES}
assert dataset.replace('_', ' ') in valid or dataset in valid, f'bad dataset: {dataset}' Prevention
- Source allowed datasets from DATASET_CHOICES at runtime instead of hardcoding strings.
- Remember underscore labels are normalized to spaces; raw .zip filenames also work.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- The request was returned empty. This may be due to an invali
- Invalid region, '{region}', for factor '{factor}'. Only 'ame
- Invalid region: '{region}'. Valid regions are: {", ".join(FA
- Invalid factor: '{factor}' for region: '{region}'. Valid fac
- Invalid frequency: '{frequency}' for factor: '{factor}' in r
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/44e34d8aa1693003.
Report an issue: GitHub.