OpenBB-finance/OpenBB · error · OpenBBError
The request was returned empty. This may be due to an invali
Error message
The request was returned empty. This may be due to an invalid, or incorrectly mapped, portfolio choice.
What it means
Fama-French country portfolio returns transform guard: extraction returned no DataFrames, and the message points at the usual root cause — a portfolio choice that is invalid or not correctly mapped to a downloadable dataset. The query param for portfolio must correspond to an actual file in the Fama-French library.
Source
Thrown at openbb_platform/providers/famafrench/openbb_famafrench/models/country_portfolio_returns.py:247
),
)
except Exception as e: # pylint: disable=broad-except
raise OpenBBError(e) from e
@staticmethod
def transform_data(
query: FamaFrenchCountryPortfolioReturnsQueryParams,
data: tuple,
**kwargs: Any,
) -> AnnotatedResult[list[FamaFrenchCountryPortfolioReturnsData]]:
"""Transform the extracted data."""
# pylint: disable=import-outside-toplevel
from pandas import MultiIndex
dfs, meta = data
if not dfs:
raise OpenBBError(
"The request was returned empty."
+ " This may be due to an invalid, or incorrectly mapped, portfolio choice."
)
returns_data = dfs[0] if isinstance(dfs, list) else dfs
# Values of -99.99 or -999 indicate no data,
# Drop columns that have no data.
for col in returns_data.columns:
if all(returns_data[col].values == "-99.99") or all(
returns_data[col].values == "-999"
):
returns_data = returns_data.drop(columns=[col])
else:
returns_data[col] = (
returns_data[col].astype(int)
if query.measure == "ratios" and col == "firms"
else returns_data[col].astype(float)
)View on GitHub (pinned to 3e071fcc2c)
Solutions
- Check the valid portfolio choices in the query param definition (Literal/choices of FamaFrenchCountryPortfolioReturnsQueryParams) and pick a listed one.
- Verify the country+portfolio pair exists in the Fama-French international returns library before querying.
- Retry to rule out a transient FTP empty response.
- Update the openbb-famafrench provider for current file mappings.
Defensive patterns
Strategy: validation
Validate before calling
from openbb_famafrench.models.country_portfolio_returns import (
FamaFrenchCountryPortfolioReturnsQueryParams,
)
import typing
valid_portfolios = typing.get_args(
FamaFrenchCountryPortfolioReturnsQueryParams.model_fields['portfolio'].annotation
) Try / catch
try:
res = await obb.economy.famafrench.country_portfolio_returns(portfolio=p, country=c, provider='famafrench')
except OpenBBError as e:
if 'invalid, or incorrectly mapped, portfolio choice' in str(e):
logger.warning('Skipping unmapped portfolio %s for %s', p, c)
continue
raise Prevention
- Source portfolio choices from the query model's Literal, not free text
- Verify country/portfolio pairs exist in the Fama-French library for batch pipelines
When it happens
Trigger: Choosing a country/portfolio combination whose returns file does not exist on the Fama-French FTP; a portfolio label that fails the internal mapping to a dataset filename, yielding an empty download.
Common situations: Assuming every country has all portfolio variants (e.g. top/bottom decile files) available; typos in portfolio names; upstream renames of portfolio files after provider release.
Related errors
- No data to process!
- No results found for the provided query.
- No data was found for the supplied date range and countries.
- No data was found for the supplied date range and countries.
- The data is unexpectedly empty. -> {query.breakpoint_type}
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/0a012ab10cc204d2.
Report an issue: GitHub.