{"record":{"id":"577e6dabfece072f","repo":"OpenBB-finance/OpenBB","slug":"error-get-code-error-get-message-577e6d","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/congress_bills.py","lineNumber":301,"sourceCode":"            + (\n                f\"&toDateTime={query.end_date.strftime('%Y-%m-%d') + 'T23:59:59Z'}\"\n                if query.end_date\n                else \"\"\n            )\n        )\n        url += (\n            f\"{'?' if '?' not in url else '&'}\"\n            + f\"limit={query.limit if query.limit is not None else '100'}\"\n            + (f\"&offset={query.offset if query.offset else '0'}\")\n            + f\"&sort=updateDate+{query.sort_by}\"\n            + f\"&format=json&api_key={api_key}\"\n        )\n\n        try:\n            response = await amake_request(url=url)\n            if isinstance(response, dict) and (error := response.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(\n                    f\"{error.get('code', '')} -> {error.get('message', '')}\"\n                )\n\n        except Exception as e:\n            # Handle exceptions\n            raise OpenBBError(e) from e\n\n        return response.get(\"bills\", [])  # type: ignore\n\n    @staticmethod\n    def transform_data(\n        query: CongressBillsQueryParams, data: list, **kwargs: Any\n    ) -> list[CongressBillsData]:\n        \"\"\"Transform raw data into CongressBillsData models.\"\"\"\n        transformed_data: list[CongressBillsData] = []","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/congress_gov/openbb_congress_gov/models/congress_bills.py#L283-L319","documentation":"UnauthorizedError from the bills listing fetcher when the congress.gov error payload's code contains 'API_KEY' — the request was rejected for missing/invalid/quota-exhausted credentials. The code and message from the API are embedded in the exception text.","triggerScenarios":"Calling obb.congress.bills without a working congress_gov_api_key; suspended key after rate-limit breaches; credential set only in a different profile/environment.","commonSituations":"Fresh setups, CI secrets not exported, multi-process jobs sharing a key past 5,000 req/hour.","solutions":["Set and verify congress_gov_api_key.","Test the key with a direct API call.","Throttle and cache to respect the hourly quota."],"exampleFix":"# before\nobb.congress.bills(congress=119)\n\n# after\nobb.account.credentials.set('congress_gov_api_key', KEY)\nobb.congress.bills(congress=119)","handlingStrategy":"validation","validationCode":"assert obb.account.credentials.get('congress_gov_api_key'), 'congress_gov_api_key required'","typeGuard":null,"tryCatchPattern":"from openbb_core.provider.utils.errors import UnauthorizedError\n\ntry:\n    res = obb.congress.bills(congress=119)\nexcept UnauthorizedError:\n    raise SystemExit('configure congress_gov_api_key') from None","preventionTips":["Preflight credentials before batch runs.","One key per workload with per-workload throttling.","Treat UnauthorizedError as an operational alert, not a code defect."],"tags":["congress-gov","auth","api-key","bills","openbb"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}