Uh oh!
There was an error while loading. Please reload this page.
feat(webapp): share rate limit bucket across additional API keys per environment - #4508
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (2)
📜 Recent review details⏰ Context from checks skipped due to timeout. (18)
WalkthroughAPI rate limits now use environment-scoped buckets. A new resolver maps valid private API keys to an environment and limiter configuration. Rate-limit middleware carries optional identifiers through override resolution, caching, validation, and bucket checks. JWT limits retain fixed-window behavior. Limits presenter lookups now use environment identifiers instead of hashed API keys. Tests cover shared buckets, isolated token buckets, preview environments, and deleted projects. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
ba817b9 to
316db63Compare@trigger.dev/buildtrigger.dev@trigger.dev/core@trigger.dev/python@trigger.dev/react-hooks@trigger.dev/redis-worker@trigger.dev/rsc@trigger.dev/schema-to-json@trigger.dev/sdkcommit: |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
316db63 to
cd2a0c0Compare
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
eb0e8f7 to
e9ae728Compare
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
10388e2 to
15b81deCompare…environment remove comments fix(webapp): bucket restricted additional API keys by environment too feat(webapp): bucket root API keys per environment too fix(webapp): version rate-limit cache key and validate cached shape on read use new resolver for api keys fix(webapp): keep environment rate-limit buckets consistent Use environment identifiers when displaying remaining API capacity and ignore additional keys tied to deleted projects. Update .server-changes/additional-api-key-rate-limit-bucket.md Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> fix(webapp): keep public API keys on separate rate-limit buckets fix limits presenter for preview branches
15b81de to
ee84c89Compare
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
What
Rate-limit the API by environment rather than per API key.
Previously the limiter keyed its bucket on the hash of the full
Authorizationheader — one bucket per key. With additional environment API keys (tr_*_sk_*), an environment can mint many keys and each got its own full bucket, so more keys = higher effective rate limit. This collapses all of an environment's keys onto a single shared per-environment bucket, so the ceiling is exactly the configured limit regardless of key mix.How
authorizationRateLimitMiddlewarenow lets the override return{ config?, identifier? }.identifier, when present, is the rate limit bucket key; otherwise it falls back to the hashedAuthorizationheader (unchanged legacy behavior, still used byengineRateLimiterand any unauthenticated fallthrough).apiRateLimiter's override resolves the environment id and uses it as the identifier:isAdditionalApiKey) resolve via a newresolveAdditionalApiKeyRateLimitScope()— a scope-agnostic keyHash → (environmentId, org limiter config) lookup. It is deliberately permissive (restricted keys resolve too) because it's used only for bucketing, never as an auth decision — request auth still goes through the RBAC bearer controller, which enforces scopes. Revoked/expired keys are excluded so they can't hold a bucket warm.authenticateAuthorizationHeaderand key onenvironment.idtoo.Behavior notes
Tests
{ config }return shape.Base:
feat/multi-keys-surface. Closes TRI-12888.