{"record":{"id":"232aaad5592a8fcc","repo":"OpenBB-finance/OpenBB","slug":"error-mapping-the-provided-choices-to-series-id","errorCode":null,"errorMessage":"Error mapping the provided choices to series ID.\n{','.join(messages) if messages else ''}","messagePattern":"Error mapping the provided choices to series ID\\.\n(.+?)","errorType":"validation","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/fred/openbb_fred/models/bond_indices.py","lineNumber":524,"sourceCode":"        if \"yield_curve\" in values[\"index\"]:\n            maturities_dict = BAML_CATEGORIES[values[\"category\"]][values[\"index\"]]  # type: ignore\n            maturities = list(maturities_dict)\n            symbols = [\n                maturities_dict[item][values[\"index_type\"]] for item in maturities\n            ]\n        else:\n            items = (\n                values[\"index\"]\n                if isinstance(values[\"index\"], list)\n                else values[\"index\"].split(\",\")\n            )\n            symbols = [\n                BAML_CATEGORIES[values[\"category\"]].get(item, {}).get(values[\"index_type\"])  # type: ignore\n                for item in items\n            ]\n            symbols = [symbol for symbol in symbols if symbol]\n        if not symbols:\n            raise OpenBBError(\n                \"Error mapping the provided choices to series ID.\"\n                + f\"\\n{','.join(messages) if messages else ''}\"\n            )\n        values[\"index\"] = \",\".join(new_index)\n        new_params = FredBondIndicesQueryParams(**values)\n        new_params._symbols = \",\".join(symbols)  # pylint: disable=protected-access\n\n        return new_params\n\n    @staticmethod\n    async def aextract_data(\n        query: FredBondIndicesQueryParams,\n        credentials: dict[str, str] | None,\n        **kwargs: Any,\n    ) -> dict:\n        \"\"\"Extract data.\"\"\"\n        api_key = credentials.get(\"fred_api_key\") if credentials else \"\"\n        series_ids = query._symbols  # pylint: disable=protected-access","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/fred/openbb_fred/models/bond_indices.py#L506-L542","documentation":"Raised in FredBondIndicesQueryParams validation when the chosen index/category/index_type combination fails to map to any FRED series ID via BAML_CATEGORIES[category].get(index, {}).get(index_type) - all lookups returned nothing, so symbols is empty. Distinct from error 454: the index name passed its category check but has no series for the requested index_type (yield vs total_return).","triggerScenarios":"Requesting index_type='total_return' for an index that only has a yield series (or vice versa), or a yield_curve branch where the maturity->series mapping lacks the chosen index_type key.","commonSituations":"Assuming every BAML index has both yield and total_return variants; using index_type='yield' for indices defined only as total-return series in the BAML_CATEGORIES structure.","solutions":["Inspect the BAML_CATEGORIES entry for your index in the module source to see which index_type keys it actually defines","Switch index_type between 'total_return' and 'yield'","Pick a different index within the category known to carry the desired index_type","Read any appended validation messages for prior-stage context"],"exampleFix":"# before\nres = await obb.economy.bond_indices(provider='fred', category='treasury', index='yield_curve', index_type='total_return').await_to_list()\n\n# after\nres = await obb.economy.bond_indices(provider='fred', category='treasury', index='yield_curve', index_type='yield').await_to_list()","handlingStrategy":"validation","validationCode":"from openbb_fred.models.bond_indices import BAML_CATEGORIES\nentry = BAML_CATEGORIES[category][index]\nif not isinstance(entry, dict) or index_type not in (entry.values() if not isinstance(next(iter(entry.values()), None), dict) else next(iter(entry.values()))):\n    raise ValueError(f'{index} has no {index_type} series')","typeGuard":"def has_index_type(index: str, category: str, index_type: str, categories: dict) -> bool:\n    entry = categories.get(category, {}).get(index)\n    if entry is None:\n        return False\n    if isinstance(next(iter(entry.values()), None), dict):\n        return any(index_type in sub for sub in entry.values())\n    return index_type in entry","tryCatchPattern":null,"preventionTips":["Check the BAML_CATEGORIES structure to confirm which index_type variants exist per index","Default to 'yield' for yield_curve indices and 'total_return' for return indices","Validate the full (category, index, index_type) triple before calling the router"],"tags":["fred","bond-indices","series-mapping","parameter-validation"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}