{"record":{"id":"1d35f29e73376ad8","repo":"OpenBB-finance/OpenBB","slug":"invalid-bill-type-bill-type-must-be-one-of-1d35f2","errorCode":null,"errorMessage":"Invalid bill type: {bill_type}. Must be one of {', '.join([option['value'] for option in bill_type_options])}.","messagePattern":"Invalid bill type: (.+?)\\. Must be one of (.+?)\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"openbb_platform/providers/congress_gov/openbb_congress_gov/utils/helpers.py","lineNumber":333,"sourceCode":"    start_date: str | None = None,\n    end_date: str | None = None,\n    bill_url: str | None = None,\n    is_document_choices: bool | None = None,\n) -> list:\n    \"\"\"Fetch a list of bills of a specific type for a given Congress number.\n\n    This function is not intended to be used directly.\n\n    It is used by the OpenBB Workspace Congressional Bills Viewer widget\n    to populate dynamic parameter choices based on the widget's state.\n    \"\"\"\n    # pylint: disable=import-outside-toplevel\n    from datetime import datetime\n\n    bills_state = BillsState()\n\n    if bill_type and bill_type not in [option[\"value\"] for option in bill_type_options]:\n        raise HTTPException(\n            status_code=500,\n            detail=f\"Invalid bill type: {bill_type}.\"\n            + f\" Must be one of {', '.join([option['value'] for option in bill_type_options])}.\",\n        )\n\n    if bill_url:\n        return await get_bill_text_choices(bill_url=bill_url)\n\n    if is_document_choices is True and not bill_url:\n        return [\n            {\n                \"label\": \"Select a bill to view associated text.\",\n                \"value\": \"\",\n            }\n        ]\n\n    if not bill_type:\n        bill_type = \"hr\"","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/congress_gov/openbb_congress_gov/utils/helpers.py#L315-L351","documentation":"The bill viewer's dynamic parameter-choices helper validates bill_type against the Workspace UI's bill_type_options list and raises HTTPException(500) when it does not match. This mirrors the BillTypes codes but is driven by the widget's option list, and it fires before any API call. The 500 status is arguably wrong for bad input (422 would be more apt) but the intent is rejecting unknown type codes early.","triggerScenarios":"Workspace widget or direct call to the bill viewer choices endpoint with bill_type='hr ' or 'HR' (matching is exact, no lowercasing here); a widget state where the type selector was edited manually rather than chosen from the dropdown.","commonSituations":"Custom dashboards reusing the widget parameter contract; hand-crafted requests to the choices endpoint; state restored from older versions whose option lists differ.","solutions":["Send an exact value from bill_type_options — lowercase, no extra whitespace","Fetch the options list first and constrain your UI to it rather than free-text input","If calling programmatically, normalize with .strip().lower() before passing"],"exampleFix":"# before\nchoices = await get_bill_viewer_choices(bill_type='HR')\n\n# after\nchoices = await get_bill_viewer_choices(bill_type='hr')","handlingStrategy":"validation","validationCode":"def valid_bill_viewer_type(bt: str, options: list[dict]) -> str:\n    values = [o['value'] for o in options]\n    if bt not in values:\n        raise ValueError(f'{bt!r} not one of {values}')\n    return bt","typeGuard":"def is_valid_viewer_bill_type(bt: str, options: list[dict]) -> bool:\n    return bt in [o['value'] for o in options]","tryCatchPattern":"from fastapi import HTTPException\ntry:\n    choices = await get_bill_viewer_choices(bill_type=bt, ...)\nexcept HTTPException as e:\n    if 'Invalid bill type' in e.detail:\n        bt = 'hr'  # reset to default and retry\n        choices = await get_bill_viewer_choices(bill_type=bt, ...)\n    else:\n        raise","preventionTips":["Drive the parameter from the widget's own options list, never free text","This check is exact-match: no case folding or trimming happens inside","Cache the options list and validate client-side before hitting the endpoint"],"tags":["congress-gov","validation","workspace","bill-type","http-exception"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}