{"record":{"id":"89fb3df87f4d8110","repo":"infiniflow/ragflow","slug":"invalid-rate-limit-per-per","errorCode":null,"errorMessage":"Invalid rate_limit.per: {per}","messagePattern":"Invalid rate_limit\\.per: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":400,"severity":"error","filePath":"api/apps/restful_apis/agent_api.py","lineNumber":1991,"sourceCode":"        \"\"\"Simple in-memory rate limiting.\"\"\"\n        rl = security_cfg.get(\"rate_limit\")\n        if not rl:\n            rl = {\"limit\": 60, \"per\": \"minute\"}\n\n        limit = int(rl.get(\"limit\", 60))\n        if limit <= 0:\n            raise Exception(\"rate_limit.limit must be > 0\")\n        per = rl.get(\"per\", \"minute\")\n\n        window = {\n            \"second\": 1,\n            \"minute\": 60,\n            \"hour\": 3600,\n            \"day\": 86400,\n        }.get(per)\n\n        if not window:\n            raise Exception(f\"Invalid rate_limit.per: {per}\")\n\n        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])","sourceCodeStart":1973,"sourceCodeEnd":2009,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/apps/restful_apis/agent_api.py#L1973-L2009","documentation":"Error \"Invalid rate_limit.per: {per}\" thrown in infiniflow/ragflow.","triggerScenarios":"Thrown at api/apps/restful_apis/agent_api.py:1991 when the library encounters an invalid state.","commonSituations":"The rate limit period uses an unsupported time unit; choosing a documented unit prevents this error.","solutions":["Use a supported rate_limit.per unit (e.g. 'second', 'minute', 'hour')."],"exampleFix":"webhook_config = {'rate_limit': {'limit': 60, 'per': 'minute'}}","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"}