{"record":{"id":"a3facd0265931224","repo":"OpenBB-finance/OpenBB","slug":"invalid-choice-choose-from-all-agency-debts","errorCode":null,"errorMessage":"Invalid choice. Choose from: ['all', 'agency debts', 'mbs', 'cmbs']","messagePattern":"Invalid choice\\. Choose from: \\['all', 'agency debts', 'mbs', 'cmbs'\\]","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/federal_reserve/openbb_federal_reserve/utils/ny_fed_api.py","lineNumber":470,"sourceCode":"        response: dict = {}\n        url: str = \"\"\n        dates = await self.get_as_of_dates()\n        if as_of is not None:\n            as_of = get_nearest_date(dates, as_of)\n        if as_of is None:\n            as_of = dates[0]\n        if wam is True:\n            url = _get_endpoints(\n                date=as_of,\n            )[\n                \"soma_holdings\"\n            ][\"agency_debts\"]\n            response = await fetch_data(url)\n            return [response.get(\"soma\", {})]\n        url = _get_endpoints(date=as_of)[\"soma_holdings\"][\"get_as_of\"]\n        if holding_type is not None:\n            if holding_type not in AGENCY_HOLDING_TYPES:\n                raise OpenBBError(\n                    \"Invalid choice. Choose from: ['all', 'agency debts', 'mbs', 'cmbs']\"\n                )\n            url = _get_endpoints(\n                agency_holding_type=AGENCY_HOLDING_TYPES[holding_type], date=as_of\n            )[\"soma_holdings\"][\"get_holding_type\"]\n        if cusip is not None:\n            url = _get_endpoints(cusips=cusip)[\"soma_holdings\"][\"get_cusip\"]\n        response = await fetch_data(url)\n        holdings = response.get(\"soma\", {}).get(\"holdings\", [])\n        if not holdings:\n            raise EmptyDataError()\n\n        return holdings\n\n    async def get_treasury_holdings(  # pylint: disable=R0917\n        self,\n        as_of: str | None = None,\n        cusip: str | None = None,","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/federal_reserve/openbb_federal_reserve/utils/ny_fed_api.py#L452-L488","documentation":"OpenBBError from SomaHoldings.get_agency_holdings: holding_type was supplied but is not a key in AGENCY_HOLDING_TYPES (accepted: 'all', 'agency debts', 'mbs', 'cmbs'). Raised before any URL is built, so it is pure input validation — note the message is a hardcoded string, not interpolated, so it always shows the same list.","triggerScenarios":"Passing holding_type='agency_debts' (underscore instead of space), 'MBS' (case-sensitive lookup), 'cmo', or 'all ' (trailing space) to get_agency_holdings.","commonSituations":"Copy-pasting URL slugs or API query-param values instead of the human-readable labels; assuming case-insensitivity; trailing whitespace from config files.","solutions":["Use exactly one of: 'all', 'agency debts', 'mbs', 'cmbs' (lowercase, spaces not underscores).","Normalize input: strip and lowercase, then check membership in the accepted set before calling.","Pass holding_type=None to get all holdings unfiltered."],"exampleFix":"// before\nholdings = await SomaHoldings().get_agency_holdings(holding_type='agency_debts')\n// after\nholdings = await SomaHoldings().get_agency_holdings(holding_type='agency debts')","handlingStrategy":"validation","validationCode":"AGENCY_HOLDING_TYPES = {'all', 'agency debts', 'mbs', 'cmbs'}\nholding_type = holding_type.strip().lower() if holding_type else None\nassert holding_type is None or holding_type in AGENCY_HOLDING_TYPES","typeGuard":"def is_valid_agency_holding_type(v) -> bool:\n    return v is None or (isinstance(v, str) and v.strip().lower() in {'all', 'agency debts', 'mbs', 'cmbs'})","tryCatchPattern":null,"preventionTips":["Normalize (strip+lower) before submitting","Remember labels use spaces, not underscores: 'agency debts'"],"tags":["openbb","ny-fed","soma","validation","enum"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}