{"record":{"id":"81213734c5fc9bdc","repo":"OpenBB-finance/OpenBB","slug":"congress-is-required-when-limit-is-set-to-0","errorCode":null,"errorMessage":"'congress' is required when 'limit' is set to 0.","messagePattern":"'congress' is required when 'limit' is set to 0\\.","errorType":"validation","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/congress_gov/openbb_congress_gov/models/congress_amendments.py","lineNumber":230,"sourceCode":"    @staticmethod\n    async def aextract_data(\n        query: CongressAmendmentsQueryParams,\n        credentials: dict[str, str] | None,\n        **kwargs: Any,\n    ) -> list:\n        \"\"\"Extract data from the Congress API.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        import asyncio\n\n        from openbb_congress_gov.utils.helpers import get_all_amendments_by_type\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\n        if query.limit == 0 and query.amendment_type is not None:\n            if query.congress is None:\n                raise OpenBBError(\n                    ValueError(\"'congress' is required when 'limit' is set to 0.\")\n                )\n\n            return await get_all_amendments_by_type(\n                congress=query.congress,\n                amendment_type=query.amendment_type,\n            )\n\n        url = f\"{base_url}amendment\"\n\n        if query.congress is not None:\n            url += f\"/{query.congress}\"\n\n            if query.amendment_type is not None:\n                url += f\"/{query.amendment_type}\"\n\n        url += f\"?limit={query.limit if query.limit is not None else 100}\"\n        url += f\"&offset={query.offset if query.offset else 0}\"","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/congress_gov/openbb_congress_gov/models/congress_amendments.py#L212-L248","documentation":"OpenBBError raised in the CongressAmendmentsFetcher.aextract_data when limit=0 and amendment_type IS set but congress is None. The 'fetch all' path delegates to get_all_amendments_by_type(congress=..., amendment_type=...), which requires a specific congress number to enumerate; without it the helper cannot paginate. Note the query validator already guarantees amendment_type is present here, so congress is the only missing piece.","triggerScenarios":"Calling obb.congress.amendments(amendment_type='hamdt', limit=0) with no congress argument — the request passes param validation but fails in the fetcher.","commonSituations":"Users assuming limit=0 + type means 'all congresses'; the two-stage validation (validator allows it, fetcher rejects it) catching people who read only the validator's error message.","solutions":["Add a congress number: amendments(congress=119, amendment_type='hamdt', limit=0).","If you truly want every congress, loop over the range of congress numbers (e.g. 93–119) with limit=0 each.","Otherwise use a positive limit without congress for the default paged listing."],"exampleFix":"# before\nobb.congress.amendments(amendment_type='hamdt', limit=0)\n\n# after\nobb.congress.amendments(congress=119, amendment_type='hamdt', limit=0)","handlingStrategy":"validation","validationCode":"if limit == 0:\n    assert amendment_type in ('hamdt', 'samdt'), 'limit=0 needs amendment_type'\n    assert congress is not None and 93 <= int(congress) <= 119, 'limit=0 needs a valid congress number'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember validation is two-stage: query params pass, the fetcher still needs congress.","Pin the congress number in config so 'fetch all' calls are always fully specified.","Loop over congress numbers when you truly need a full historical sweep."],"tags":["congress-gov","validation","congress-number","amendments","openbb"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}