OpenBB-finance/OpenBB · error · ValueError
Expected dict, got empty list
Error message
Expected dict, got empty list
What it means
Raised by openbb_fmp get_data_one when the FMP response is a list with zero elements but the caller needs a single dict. The helper is used for endpoints expected to return one object (profile, quote, etc.), so an empty list means the symbol simply has no record.
Solutions
- Validate the symbol with FMP's search endpoint (/api/v3/search?query=...) and use the returned symbol exactly
- Check for delisting or exchange-specific formatting (FMP uses hyphens for share classes, e.g. BRK-B)
- Confirm the endpoint covers that asset class
- Handle the ValueError in caller code to skip unknown symbols in batch loops
Example fix
# before
profile = await get_data_one(f"{base}profile?symbol={symbol}&apikey={key}")
# after
try:
profile = await get_data_one(f"{base}profile?symbol={symbol}&apikey={key}")
except ValueError:
continue # skip symbols FMP does not cover Defensive patterns
Strategy: try-catch
Validate before calling
import requests
r = requests.get(f"https://financialmodelingprep.com/stable/search-ticker?query={symbol}&apikey={key}")
matches = r.json() if r.status_code == 200 else []
assert matches, f'{symbol} unknown to FMP' Type guard
def symbol_exists_on_fmp(symbol: str, search_results: list[dict]) -> bool:
return any(item.get("symbol") == symbol for item in search_results) Try / catch
try:
profile = await get_data_one(url)
except ValueError as e:
if 'empty list' in str(e):
continue # symbol not covered - skip in batch loops
raise Prevention
- Pre-validate tickers against FMP's search endpoint and cache the result
- Normalize share-class separators to FMP's hyphen format (BRK-B, BF-B)
- Wrap per-symbol calls in ValueError handlers in batch pipelines
When it happens
Trigger: Calling a single-object FMP endpoint (e.g. /profile/) with a symbol FMP does not cover: invalid ticker, wrong exchange suffix, delisted company, or an asset class (crypto/forex) the endpoint does not serve.
Common situations: Typos in tickers (APPL vs AAPL), tickers with dots or suffixes FMP does not use (BRK.B vs BRK-B), recently delisted companies, or free-tier keys restricted from certain symbols.
Related errors
- Adjustment can only be applied to daily ('1d') interval.
- Country ' ' ( ) is not supported by FMP. Valid options: ...
- Date range cannot exceed 90 days.
- Either symbol or cik must be provided.
- Exchange ' ' ( ) is not supported by FMP. Valid options: ...
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/3a6b3769e596d738.
Report an issue: GitHub.
Appendix: source
Thrown at openbb_platform/providers/fmp/openbb_fmp/utils/helpers.py:133
"""
data = await get_data(url, **kwargs)
if sub_dict and isinstance(data, dict):
data = data.get(sub_dict, [])
if isinstance(data, dict):
raise ValueError("Expected list of dicts, got dict")
if len(data) == 0:
raise EmptyDataError()
return data
async def get_data_one(url: str, **kwargs: Any) -> dict:
"""Get data from FMP endpoint and convert to schema."""
data = await get_data(url, **kwargs)
if isinstance(data, list):
if len(data) == 0:
raise ValueError("Expected dict, got empty list")
try:
data = {i: data[i] for i in range(len(data))} if len(data) > 1 else data[0]
except TypeError as e:
raise ValueError("Expected dict, got list of dicts") from e
return data
def most_recent_quarter(base: date | None = None) -> date:
"""Get the most recent quarter date."""
if base is None:
base = date.today()
base = min(base, date.today()) # This prevents dates from being in the future
exacts = [(3, 31), (6, 30), (9, 30), (12, 31)]
for exact in exacts:
if base.month == exact[0] and base.day == exact[1]:
return baseView on GitHub (pinned to 3e071fcc2c)