{"record":{"id":"4468a84b1fdef08f","repo":"OpenBB-finance/OpenBB","slug":"error-get-code-error-get-message-4468a8","errorCode":null,"errorMessage":"{error.get('code', '')} -> {error.get('message', '')}","messagePattern":"\\{error\\.get\\('code', ''\\)\\} -> \\{error\\.get\\('message', ''\\)\\}","errorType":"exception","errorClass":"UnauthorizedError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/congress_gov/openbb_congress_gov/models/bill_info.py","lineNumber":103,"sourceCode":"        from openbb_core.app.model.abstract.error import OpenBBError\n        from openbb_core.provider.utils.errors import UnauthorizedError\n        from openbb_core.provider.utils.helpers import amake_request\n\n        api_key = credentials.get(\"congress_gov_api_key\", \"\") if credentials else \"\"\n        bill_url = query.bill_url\n        if bill_url[0].isnumeric() or (bill_url[0] == \"/\" and bill_url[1].isnumeric()):\n            # If the bill URL starts with a number, assume it's a congress number and construct the URL\n            bill_url = (\n                \"https://api.congress.gov/v3/bill/\"\n                + f\"{bill_url[1:] if bill_url[0] == '/' else bill_url}?format=json\"\n            )\n\n        url = bill_url + \"&api_key=\" + api_key\n        base_info: dict = await amake_request(url)  # type: ignore\n\n        if isinstance(base_info, dict) and (error := base_info.get(\"error\", {})):\n            if \"API_KEY\" in error.get(\"code\", \"\"):\n                raise UnauthorizedError(\n                    f\"{error.get('code', '')} -> {error.get('message', '')}\"\n                )\n            raise OpenBBError(f\"{error.get('code', '')} -> {error.get('message', '')}\")\n\n        base_info = base_info.get(\"bill\", {})\n        cosponsors = base_info.get(\"cosponsors\", {})\n\n        if cosponsors.get(\"count\", 0) > 0:\n            cosponsors_url = (\n                base_info.get(\"cosponsors\", {}).get(\"url\", \"\") + \"&api_key=\" + api_key\n            )\n            cosponsors_response: dict = await amake_request(cosponsors_url)  # type: ignore\n            cosponsors_list = cosponsors_response.get(\"cosponsors\", [])\n            base_info[\"cosponsors\"] = cosponsors_list\n\n        subjects = base_info.get(\"subjects\", {})\n\n        if subjects.get(\"count\", 0) > 0:","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/congress_gov/openbb_congress_gov/models/bill_info.py#L85-L121","documentation":"UnauthorizedError raised by the congress.gov bill-info fetcher when the response error code contains 'API_KEY' — the credentials supplied for congress_gov_api_key were rejected. Identical auth semantics to the amendment endpoint: it exists so OpenBB surfaces credential problems distinctly from other upstream errors.","triggerScenarios":"Calling CongressBillInfo with a missing, expired, revoked, or quota-exhausted congress_gov_api_key; the key set in a different OpenBB profile than the one running the request.","commonSituations":"New machine/profile without stored credentials; the 5,000 requests/hour limit hit by scheduled jobs; stale keys after re-registering on api.congress.gov.","solutions":["Provision the key: obb.account.credentials.set('congress_gov_api_key', '<key>').","Confirm the key independently with a direct API call before blaming OpenBB.","Cache bill-info responses locally to stay under the hourly quota."],"exampleFix":"# before\nobb.congress.bill_info(bill_url='119/hr/1')\n\n# after\nobb.account.credentials.set('congress_gov_api_key', KEY)\nobb.congress.bill_info(bill_url='119/hr/1')","handlingStrategy":"validation","validationCode":"key = obb.account.credentials.get('congress_gov_api_key')\nif not key:\n    raise RuntimeError('congress_gov_api_key missing — set it before querying bills')","typeGuard":null,"tryCatchPattern":"from openbb_core.provider.utils.errors import UnauthorizedError\n\ntry:\n    res = obb.congress.bill_info(bill_url='119/hr/1')\nexcept UnauthorizedError:\n    raise SystemExit('Set a valid congress_gov_api_key') from None","preventionTips":["Provision the credential in every environment/profile that runs the job.","Verify keys after registration and before deadlines/deploys.","Share one key sparingly; quota is per key."],"tags":["congress-gov","auth","api-key","credentials","openbb"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}