OpenBB-finance/OpenBB · error · OpenBBError

Invalid dataset, {dataset}

Error message

Invalid dataset, {dataset}

What it means

Fama-French factors extraction guard: the dataset filename is composed as portfolio + interval (looked up from FACTOR_REGION_MAP for the query's region/factor/frequency). If either lookup misses, dataset is '' and the fetch aborts with this OpenBBError. In normal flow the model validator (errors 335-338) rejects such combinations first, so hitting this means the query object was constructed bypassing validation.

Source

Thrown at openbb_platform/providers/famafrench/openbb_famafrench/models/factors.py:279

    @staticmethod
    async def aextract_data(
        query: FamaFrenchFactorsQueryParams,
        credentials: dict[str, str] | None,
        **kwargs: Any,
    ) -> tuple:
        """Extract the data from the FTP."""
        # pylint: disable=import-outside-toplevel, broad-except
        from openbb_famafrench.utils.helpers import get_portfolio_data

        factors = FACTOR_REGION_MAP.get(query.region, {})
        factor = factors_dict.get(query.factor, "")
        portfolio = factors.get("factors", {}).get(factor, "")
        interval = factors.get("intervals", {}).get(factor, {}).get(query.frequency, "")
        dataset = portfolio + interval

        if not dataset:
            raise OpenBBError(f"Invalid dataset, {dataset}")

        try:
            return get_portfolio_data(
                dataset=dataset,
                frequency=query.frequency,
            )
        except Exception as e:
            raise OpenBBError(original=e) from e

    @staticmethod
    def transform_data(
        query: FamaFrenchFactorsQueryParams,
        data: tuple,
        **kwargs: Any,
    ) -> AnnotatedResult[list[FamaFrenchFactorsData]]:
        """Transform the raw data and insert metadata."""
        # pylint: disable=import-outside-toplevel
        from pandas import to_datetime

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Construct the query through normal validation (FamaFrenchFactorsQueryParams(**params)) so errors 335-338 catch bad combos with clear messages.
  2. Verify the (region, factor, frequency) triple against FACTOR_REGION_MAP and factors_dict.
  3. Reinstall/align the openbb-famafrench package version so the maps are consistent.

Example fix

# before
q = FamaFrenchFactorsQueryParams.model_construct(region='europe', factor='st_reversal', frequency='monthly')
await fetcher.aextract_data(q, None)

# after
q = FamaFrenchFactorsQueryParams(region='europe', factor='5_factors', frequency='monthly')  # validators run
Defensive patterns

Strategy: validation

Validate before calling

from openbb_famafrench.models.factors import FACTOR_REGION_MAP, factors_dict

def dataset_resolves(region: str, factor: str, frequency: str) -> bool:
    f = factors_dict.get(factor, '')
    block = FACTOR_REGION_MAP.get(region, {})
    portfolio = block.get('factors', {}).get(f, '')
    interval = block.get('intervals', {}).get(f, {}).get(frequency, '')
    return bool(portfolio + interval)

Try / catch

try:
    res = await obb.economy.famafrench.factors(factor=f, region=r, frequency=frq, provider='famafrench')
except OpenBBError as e:
    if 'Invalid dataset' in str(e):
        raise ValueError('Bypassed validation — build query via the params model') from e
    raise

Prevention

When it happens

Trigger: Instantiating FamaFrenchFactorsQueryParams.model_construct(...) or otherwise skipping validators with a mismatched region/factor/frequency; FACTOR_REGION_MAP keys drifting out of sync with factors_dict after a partial upgrade.

Common situations: See trigger scenarios.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/841055f570504b93. Report an issue: GitHub.