{"record":{"id":"9d6b621aad097630","repo":"OpenBB-finance/OpenBB","slug":"invalid-bill-type-bill-type-must-be-one-of","errorCode":null,"errorMessage":"Invalid bill type: {bill_type}. Must be one of {', '.join(BillTypes)}.","messagePattern":"Invalid bill type: (.+?)\\. Must be one of (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/congress_gov/openbb_congress_gov/utils/helpers.py","lineNumber":195,"sourceCode":"        The number of results to skip before starting to collect the result set.\n        Defaults to 0 if None.\n    sort_by : Literal[\"asc\", \"desc\"]\n        The sort order for the results. Defaults to \"desc\".\n\n    Returns\n    -------\n    dict\n        A dictionary of the raw JSON response from the API.\n    \"\"\"\n    # pylint: disable=import-outside-toplevel\n    from datetime import (  # noqa\n        date as dateType,\n        datetime,\n    )\n    from openbb_core.provider.utils.helpers import amake_request\n\n    if bill_type and bill_type not in BillTypes:\n        raise ValueError(\n            f\"Invalid bill type: {bill_type}. Must be one of {', '.join(BillTypes)}.\"\n        )\n\n    api_key = check_api_key()\n\n    if start_date is None and end_date is None and congress is None:\n        congress = year_to_congress(datetime.now().year)\n    elif congress is None and start_date is not None:\n        congress = year_to_congress(dateType.fromisoformat(start_date).year)\n    elif congress is None and end_date is not None and start_date is None:\n        congress = year_to_congress(dateType.fromisoformat(end_date).year)\n    elif start_date is not None and end_date is not None:\n        start_year = dateType.fromisoformat(start_date).year\n        end_year = dateType.fromisoformat(end_date).year\n        congress_start = year_to_congress(start_year)\n        congress_end = year_to_congress(end_year)\n        if congress_start != congress_end:\n            raise ValueError(","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/congress_gov/openbb_congress_gov/utils/helpers.py#L177-L213","documentation":"get_bills_by_type validates the bill_type argument against the BillTypes constant (['hr','s','hjres','sjres','hconres','sconres','hres','sres']) and raises ValueError on anything else. Note the check is case-sensitive here — the sibling get_all_bills lowercases first, but this path does not, so 'HR' fails as well as 'bill'. The bill type forms the URL path segment, so an invalid value would otherwise 404 at the API.","triggerScenarios":"Calling get_bills_by_type(bill_type='HR') (uppercase); passing 'hres ' with whitespace; passing a made-up type like 'hrbill' or a law type like 'pub'.","commonSituations":"User input not normalized to lowercase; confusion with other taxonomies (law types 'pub'/'priv', amendment types); data pipelines passing display labels ('House Report') instead of codes.","solutions":["Normalize input: bill_type = bill_type.strip().lower() before calling","Use only the eight valid codes: hr, s, hjres, sjres, hconres, sconres, hres, sres","Validate against openbb_congress_gov.utils.constants.BillTypes at your boundary for a better error message"],"exampleFix":"# before\nres = await get_bills_by_type(congress=118, bill_type='HR')\n\n# after\nres = await get_bills_by_type(congress=118, bill_type='hr')","handlingStrategy":"validation","validationCode":"from openbb_congress_gov.utils.constants import BillTypes\n\ndef normalize_bill_type(bt: str | None) -> str | None:\n    if bt is None:\n        return None\n    bt = bt.strip().lower()\n    if bt not in BillTypes:\n        raise ValueError(f'{bt!r} not in {BillTypes}')\n    return bt","typeGuard":"from openbb_congress_gov.utils.constants import BillTypes\n\ndef is_valid_bill_type(bt: str | None) -> bool:\n    return bt is None or bt.strip().lower() in BillTypes","tryCatchPattern":null,"preventionTips":["Lowercase and strip before calling — this code path is case-sensitive","Constrain UI inputs to the eight codes via a dropdown","Validate once against BillTypes at your boundary instead of relying on the helper"],"tags":["congress-gov","validation","bill-type","case-sensitivity"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}