OpenBB-finance/OpenBB · error · ValueError
'{item}' is not available. Did you mean '{similar}'?
Error message
'{item}' is not available. Did you mean '{similar}'? What it means
Raised by openbb_core.provider.utils.helpers.check_item(item, allowed, threshold=0.75). It validates that a string is a member of an allowed list; on failure it computes difflib SequenceMatcher similarity against every allowed value and, if the best score exceeds the threshold, suggests the closest match ('Did you mean ...?'), otherwise raises the plain '{item} is not available.' variant. It is used to validate enum-like query parameters (e.g. provider names, sort/period values) before a fetch.
Source
Thrown at openbb_platform/core/openbb_core/provider/utils/helpers.py:58
item : str
The item to check.
allowed : list[str]
The list of allowed items.
threshold : float, optional
The similarity threshold for the error message, by default 0.75
Raises
------
ValueError
If the item is not in the allowed list.
"""
if item not in allowed:
similarities = map(
lambda c: (c, SequenceMatcher(None, item, c).ratio()), allowed
)
similar, score = max(similarities, key=lambda x: x[1])
if score > threshold:
raise ValueError(f"'{item}' is not available. Did you mean '{similar}'?")
raise ValueError(f"'{item}' is not available.")
def get_querystring(items: dict, exclude: list[str]) -> str:
"""Turn a dictionary into a querystring, excluding the keys in the exclude list.
Parameters
----------
items: dict
The dictionary to be turned into a querystring.
exclude: list[str]
The keys to be excluded from the querystring.
Returns
-------
str
The querystring.View on GitHub (pinned to 3e071fcc2c)
Solutions
- Read the suggestion in the message: if it says "Did you mean 'X'?", use X
- List the accepted values from the endpoint's OpenAPI schema (GET /api/v1/docs or obb.<router>.<endpoint> docstring) and use one verbatim
- For providers: check obb.user.provider_settings or the installed provider packages (pip list | grep openbb) before naming one
Example fix
# before res = await obb.equity.price.historical(symbol="AAPL", provider="yahoofinance") # ValueError: 'yahoofinance' is not available. Did you mean 'yfinance'? # after res = await obb.equity.price.historical(symbol="AAPL", provider="yfinance")
Defensive patterns
Strategy: validation
Validate before calling
from difflib import SequenceMatcher
def check_allowed(item: str, allowed: list[str], threshold: float = 0.75) -> str:
if item in allowed:
return item
best = max(allowed, key=lambda c: SequenceMatcher(None, item, c).ratio())
if SequenceMatcher(None, item, best).ratio() > threshold:
return best # accept the suggestion programmatically
raise ValueError(f"'{item}' has no close match in {allowed}")
provider = check_allowed(provider_name, ["yfinance", "tradier", "cboe"]) Type guard
def is_allowed_item(item: str, allowed: list[str]) -> bool:
return item in allowed Try / catch
try:
res = await obb.equity.price.historical(symbol=sym, provider=provider)
except ValueError as e:
if "is not available" in str(e):
raise ValueError(f"bad enum value: {e}; allowed={allowed_list}") from e
raise Prevention
- Drive enum parameters from constants/enums in your code, never free-typed strings
- Fetch the endpoint's parameter schema from the OpenAPI docs and validate inputs against it client-side
- Log the 'Did you mean' suggestion and surface it to users instead of swallowing the ValueError
When it happens
Trigger: Calling a REST/Python endpoint with a misspelled or unsupported enum value, e.g. provider='yahoofinace' (typo -> 'Did you mean yfinance?'), sort='maket_cap', or a value valid for one endpoint but not the one being called.
Common situations: Typos in parameter values, values from an outdated API reference (a sort option renamed between versions), or passing a provider that is not installed.
Related errors
- Incorrect email or password
- Invalid format for URLs. Must be str, dict, or list.
- Invalid parse_as value. Must be one of 'table', 'chart', or
- vx_type must be one of: 'am', 'eod'
- Invalid amendment_type: {values.amendment_type}. Must be one
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/1d0abcc5336c288e.
Report an issue: GitHub.