{"record":{"id":"694b21994bfc8150","repo":"OpenBB-finance/OpenBB","slug":"bill-url-is-required-please-provide-a-valid-bill","errorCode":null,"errorMessage":"Bill URL is required. Please provide a valid bill URL or number.","messagePattern":"Bill URL is required\\. Please provide a valid bill URL or number\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"openbb_platform/providers/congress_gov/openbb_congress_gov/router/congress_gov_router.py","lineNumber":163,"sourceCode":"    Returns\n    -------\n    list[dict]\n        Returns a list of dictionaries with 'label' and 'value' keys, when `is_workspace` is True.\n        Otherwise, returns the 'text' object from the Congress.gov API response.\n    \"\"\"\n    # pylint: disable=import-outside-toplevel\n    from openbb_congress_gov.utils.helpers import get_bill_text_choices\n\n    if not bill_url and is_workspace is True:\n        return [\n            {\n                \"label\": \"Enter a valid bill URL to view available documents.\",\n                \"value\": \"\",\n            }\n        ]\n\n    if not bill_url:\n        raise HTTPException(\n            status_code=500,\n            detail=\"Bill URL is required. Please provide a valid bill URL or number.\",\n        )\n\n    if (bill_url.startswith(\"/\") and bill_url[1].isdigit()) or bill_url[0].isdigit():\n        # If the bill_url is a number, assume it is a congress number and append the base URL\n        base_url = \"https://api.congress.gov/v3/bill\"\n        bill_url = (\n            base_url + bill_url\n            if bill_url.startswith(\"/\")\n            else (base_url + \"/\" + bill_url if bill_url[0].isdigit() else bill_url)\n        ) + \"?format=json\"\n\n    return await get_bill_text_choices(bill_url=bill_url, is_workspace=is_workspace)\n\n\n@router.command(\n    model=\"CongressBillInfo\",","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/congress_gov/openbb_congress_gov/router/congress_gov_router.py#L145-L181","documentation":"HTTPException(500) from the OpenBB congress.gov FastAPI router when a bill-text-choices endpoint is called with an empty bill_url outside workspace mode. Workspace mode returns a friendly placeholder list instead; a plain API call gets a hard 500 because there is no bill to enumerate documents for. Note the 500 status is arguably wrong for a client-input problem — expect it to feel like a server error in traces.","triggerScenarios":"GET /api/v1/congress_gov/bill_text_choices with no bill_url query param (and is_workspace false/absent); a UI bug clearing the field before submission.","commonSituations":"Custom frontends calling the router directly; curl/python tests omitting the required param; form state bugs that submit empty strings.","solutions":["Always pass bill_url, either a full v3 URL or a 'congress/type/number' shorthand (e.g. '119/hr/1') that the router expands.","In frontend code, disable the submit action until the field is non-empty.","If you rely on workspace UX behavior, pass is_workspace=true to get the placeholder payload instead of the 500."],"exampleFix":"# before\nobb.congress.gov_router.bill_text_choices(bill_url='')\n\n# after\nobb.congress.gov_router.bill_text_choices(bill_url='119/hr/1')","handlingStrategy":"validation","validationCode":"if not bill_url or not bill_url.strip():\n    raise ValueError('bill_url is required (e.g. \"119/hr/1\" or a full v3 URL)')","typeGuard":"import re\n\ndef is_bill_shorthand(v: str) -> bool:\n    return bool(re.fullmatch(r'\\d{2,3}/(hr|s|hjres|sjres|hconres|sconres|hres|sres)/\\d+', v))","tryCatchPattern":"from fastapi import HTTPException\n\ntry:\n    choices = await get_bill_text_choices(bill_url=bill_url)\nexcept HTTPException as e:\n    if e.status_code == 500 and 'Bill URL is required' in e.detail:\n        return render_empty_state()\n    raise","preventionTips":["Disable submit until bill_url is non-empty in frontends.","Prefer the compact shorthand to avoid URL-format mistakes.","Pass is_workspace=true when you want placeholder payloads for empty input."],"tags":["congress-gov","router","http-exception","required-param","openbb"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}