{"record":{"id":"cd46e81cebd8fb29","repo":"OpenBB-finance/OpenBB","slug":"invalid-choice-choose-from-join-treasury-h","errorCode":null,"errorMessage":"Invalid choice. Choose from: {', '.join(TREASURY_HOLDING_TYPES)}","messagePattern":"Invalid choice\\. Choose from: (.+?)","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/federal_reserve/openbb_federal_reserve/utils/ny_fed_api.py","lineNumber":542,"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            ][\"get_treasury_debts\"]\n            response = await fetch_data(url)\n            return [response.get(\"soma\", {})]\n\n        if holding_type is not None:\n            if holding_type not in TREASURY_HOLDING_TYPES:\n                raise OpenBBError(\n                    f\"Invalid choice. Choose from: {', '.join(TREASURY_HOLDING_TYPES)}\"\n                )\n            url = _get_endpoints(treasury_holding_type=holding_type, date=as_of)[\n                \"soma_holdings\"\n            ][\"get_treasury_holding_type\"]\n        if monthly:\n            url = _get_endpoints()[\"soma_holdings\"][\"get_treasury_monthly\"]\n        if cusip is not None:\n            url = _get_endpoints(cusips=cusip)[\"soma_holdings\"][\"get_treasury_cusip\"]\n\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","sourceCodeStart":524,"sourceCodeEnd":559,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/federal_reserve/openbb_federal_reserve/utils/ny_fed_api.py#L524-L559","documentation":"OpenBBError from SomaHoldings.get_treasury_holdings: holding_type was supplied but is not in TREASURY_HOLDING_TYPES. Unlike the agency variant (377) this message is interpolated from the actual TREASURY_HOLDING_TYPES collection, so it reflects the real accepted values (typically 'bills', 'notes', 'bonds', 'frns', 'tips', 'cmbs' style labels).","triggerScenarios":"Passing holding_type='bill' (singular), 'Notes' (wrong case), or a type valid for agency holdings but not treasuries to get_treasury_holdings.","commonSituations":"Reusing the agency holding-type vocabulary for treasury queries; singular/plural mismatches; case-sensitive lookups from unnormalized user input.","solutions":["Use a value from the message's list exactly (case-sensitive match against TREASURY_HOLDING_TYPES).","Normalize: strip/lower input and validate against the collection before calling.","Pass holding_type=None for all treasury holdings."],"exampleFix":"// before\nh = await SomaHoldings().get_treasury_holdings(holding_type='bill')\n// after\nh = await SomaHoldings().get_treasury_holdings(holding_type='bills')  # exact key from TREASURY_HOLDING_TYPES","handlingStrategy":"validation","validationCode":"from openbb_federal_reserve.utils.ny_fed_api import TREASURY_HOLDING_TYPES\nholding_type = holding_type.strip().lower() if holding_type else None\nassert holding_type is None or holding_type in TREASURY_HOLDING_TYPES, f'use: {\", \".join(TREASURY_HOLDING_TYPES)}'","typeGuard":"def is_valid_treasury_holding_type(v, valid: set[str]) -> bool:\n    return v is None or (isinstance(v, str) and v.strip().lower() in valid)","tryCatchPattern":null,"preventionTips":["Don't reuse agency-holding vocabulary for treasury queries","Read TREASURY_HOLDING_TYPES from the module instead of hardcoding"],"tags":["openbb","ny-fed","soma","validation","enum"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}