{"record":{"id":"1d0abcc5336c288e","repo":"OpenBB-finance/OpenBB","slug":"item-is-not-available-did-you-mean-similar","errorCode":null,"errorMessage":"'{item}' is not available. Did you mean '{similar}'?","messagePattern":"'(.+?)' is not available\\. Did you mean '(.+?)'\\?","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/core/openbb_core/provider/utils/helpers.py","lineNumber":58,"sourceCode":"    item : str\n        The item to check.\n    allowed : list[str]\n        The list of allowed items.\n    threshold : float, optional\n        The similarity threshold for the error message, by default 0.75\n\n    Raises\n    ------\n    ValueError\n        If the item is not in the allowed list.\n    \"\"\"\n    if item not in allowed:\n        similarities = map(\n            lambda c: (c, SequenceMatcher(None, item, c).ratio()), allowed\n        )\n        similar, score = max(similarities, key=lambda x: x[1])\n        if score > threshold:\n            raise ValueError(f\"'{item}' is not available. Did you mean '{similar}'?\")\n        raise ValueError(f\"'{item}' is not available.\")\n\n\ndef get_querystring(items: dict, exclude: list[str]) -> str:\n    \"\"\"Turn a dictionary into a querystring, excluding the keys in the exclude list.\n\n    Parameters\n    ----------\n    items: dict\n        The dictionary to be turned into a querystring.\n\n    exclude: list[str]\n        The keys to be excluded from the querystring.\n\n    Returns\n    -------\n    str\n        The querystring.","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/core/openbb_core/provider/utils/helpers.py#L40-L76","documentation":"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.","triggerScenarios":"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.","commonSituations":"Typos in parameter values, values from an outdated API reference (a sort option renamed between versions), or passing a provider that is not installed.","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"],"exampleFix":"# before\nres = await obb.equity.price.historical(symbol=\"AAPL\", provider=\"yahoofinance\")\n# ValueError: 'yahoofinance' is not available. Did you mean 'yfinance'?\n\n# after\nres = await obb.equity.price.historical(symbol=\"AAPL\", provider=\"yfinance\")","handlingStrategy":"validation","validationCode":"from difflib import SequenceMatcher\n\ndef check_allowed(item: str, allowed: list[str], threshold: float = 0.75) -> str:\n    if item in allowed:\n        return item\n    best = max(allowed, key=lambda c: SequenceMatcher(None, item, c).ratio())\n    if SequenceMatcher(None, item, best).ratio() > threshold:\n        return best  # accept the suggestion programmatically\n    raise ValueError(f\"'{item}' has no close match in {allowed}\")\n\nprovider = check_allowed(provider_name, [\"yfinance\", \"tradier\", \"cboe\"])","typeGuard":"def is_allowed_item(item: str, allowed: list[str]) -> bool:\n    return item in allowed","tryCatchPattern":"try:\n    res = await obb.equity.price.historical(symbol=sym, provider=provider)\nexcept ValueError as e:\n    if \"is not available\" in str(e):\n        raise ValueError(f\"bad enum value: {e}; allowed={allowed_list}\") from e\n    raise","preventionTips":["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"],"tags":["validation","enum","did-you-mean","query-params"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}