{"record":{"id":"cffc71db862d22aa","repo":"infiniflow/ragflow","slug":"too-many-requests-rate-limit-exceeded","errorCode":null,"errorMessage":"Too many requests (rate limit exceeded)","messagePattern":"Too many requests \\(rate limit exceeded\\)","errorType":"exception","errorClass":"Exception","httpStatus":400,"severity":"error","filePath":"api/apps/restful_apis/agent_api.py","lineNumber":2011,"sourceCode":"        capacity = limit\n        rate = limit / window\n        cost = 1\n\n        key = f\"rl:tb:{agent_id}\"\n        now = time.time()\n\n        try:\n            from rag.utils.redis_conn import REDIS_CONN\n\n            res = REDIS_CONN.lua_token_bucket(\n                keys=[key],\n                args=[capacity, rate, now, cost],\n                client=REDIS_CONN.REDIS,\n            )\n\n            allowed = int(res[0])\n            if allowed != 1:\n                raise Exception(\"Too many requests (rate limit exceeded)\")\n\n        except Exception as e:\n            raise Exception(f\"Rate limit error: {e}\")\n\n    def _validate_token_auth(security_cfg):\n        \"\"\"Validate header-based token authentication.\"\"\"\n        token_cfg = security_cfg.get(\"token\", {})\n        header = token_cfg.get(\"token_header\")\n        token_value = token_cfg.get(\"token_value\")\n\n        provided = request.headers.get(header)\n        if provided != token_value:\n            raise Exception(\"Invalid token authentication\")\n\n    def _validate_basic_auth(security_cfg):\n        \"\"\"Validate HTTP Basic Auth credentials.\"\"\"\n        auth_cfg = security_cfg.get(\"basic_auth\", {})\n        username = auth_cfg.get(\"username\")","sourceCodeStart":1993,"sourceCodeEnd":2029,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/apps/restful_apis/agent_api.py#L1993-L2029","documentation":"Error \"Too many requests (rate limit exceeded)\" thrown in infiniflow/ragflow.","triggerScenarios":"Thrown at api/apps/restful_apis/agent_api.py:2011 when the library encounters an invalid state.","commonSituations":"A webhook caller exceeds the configured requests-per-period allowance; throttling the client prevents this error.","solutions":["Reduce the request rate or implement exponential backoff and retry.","Raise the webhook rate limit if the traffic is legitimate."],"exampleFix":"import time\n# on 429: time.sleep(backoff); retry","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}