fix(rate-limit): enforce user group limits for API keys - #6980
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughThe middleware now applies model rate limits from the user group only. A new integration test verifies that a token group cannot override the user group's configured limit. ChangesUser-group rate limiting
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change makes account-level rate-limit policies authoritative over API-key routing groups and adds regression coverage for the bypass scenario. No actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
51fdfc5 to
2b6f1df
Compare
Important
Note
This change and PR description were AI-assisted with Codex for LiaoQi98. The PR is opened as a draft for human and maintainer review.
📝 变更描述 / Description
Model request rate-limit groups are documented and configured as user-group policies, but the middleware previously preferred the API key's routing group. A user in a restricted group could therefore create a key assigned to
default(or another less-restricted usable group) and fall back to that group's or the global request limit.This change always selects
ContextKeyUserGroupwhen resolvingModelRequestRateLimitGroup. API key groups continue to control routing, but can no longer override the account's rate-limit policy.The regression test configures a
paiduser group with a one-request limit and adefaultkey group with a ten-request limit. It verifies that the second request is rejected with HTTP 429, proving the user-group limit remains authoritative.🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
Summary by CodeRabbit