Skip to content

feat(api): separate rate limit budget for deployment endpoints - #4565

Merged
myftija merged 1 commit into
mainfrom
feat/deployment-rate-limiter-tri-13144
Aug 11, 2026
Merged

feat(api): separate rate limit budget for deployment endpoints#4565
myftija merged 1 commit into
mainfrom
feat/deployment-rate-limiter-tri-13144

Conversation

@myftija

@myftija myftija commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Most deploy-flow API calls shared the general per-environment rate limit bucket with all of that environment's runtime traffic, so an org with heavy API usage could intermittently 429 its own deploys; the /api/v*/deployments endpoints themselves were fully exempt from rate limits as a stopgap (#2774), which promised a dedicated limiter as the follow-up. This is that follow-up: the whole deploy-flow group now runs on its own budget, separate from runtime API limits.

Design

A new deploymentRateLimiter covers every endpoint the deploy flow depends on: the /api/v*/deployments group, the env API key exchange (/api/v1/projects/:ref/:env), build-time env var resolution and sync (/envvars, /envvars/:slug/import), preview branches, /api/v1/remote-build-provider-status and /api/v1/artifacts. The general API limiter whitelists the same shared path list, so exactly one limiter applies to each path and the two can't drift apart.

Buckets are keyed per environment for environment API keys and per token for the PAT-authenticated phase of a CLI deploy (whoami, key exchange, branches). The deploy budget is controlled via the DEPLOYMENT_RATE_LIMIT_* env vars.

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 189a3b3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The PR adds shared matching rules for deployment API endpoints and tests positive and negative path cases. It adds a Redis-backed deployment rate limiter with environment-configured token budgets, logging, caching, and private API-key scoping. The server loads and orders the limiter after the general API limiter. The change exports the limiter and documents its environment variables and separate budget.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the design and scope but omits the required issue link, checklist, testing, changelog, and screenshots sections. Add the required template sections, link the closing issue, complete the checklist, document testing steps, add a changelog entry, and state whether screenshots apply.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: a separate rate-limit budget for deployment endpoints.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/deployment-rate-limiter-tri-13144

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@myftija myftija changed the title feat(webapp): separate rate limit budget for deployment endpoints feat(api): separate rate limit budget for deployment endpoints Aug 11, 2026
coderabbitai[bot]

This comment was marked as resolved.

@myftija
myftija force-pushed the feat/deployment-rate-limiter-tri-13144 branch 3 times, most recently from 1c91608 to f71b500 Compare August 11, 2026 15:02
Most deploy-flow API calls (build-time env var resolution and sync, env key
exchange, preview branches) drew from the same general API rate limit
bucket as an environment's runtime traffic, so a busy environment could
starve its own deployments; the /api/v*/deployments endpoints themselves
were fully exempt from rate limits as a stopgap. The whole group now goes
through a dedicated limiter with its own token bucket, keyed per
environment for environment API keys and per token for PATs/OATs,
configurable via DEPLOYMENT_RATE_LIMIT_* env vars. The general API limiter
whitelists the group via a shared path list. /api/v1/deployments/current is
runtime SDK surface and stays exempt from rate limits as before, outside
the deploy budget.
@myftija
myftija force-pushed the feat/deployment-rate-limiter-tri-13144 branch from f71b500 to 189a3b3 Compare August 11, 2026 15:14
@myftija
myftija marked this pull request as ready for review August 11, 2026 15:19

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment thread apps/webapp/app/services/deploymentApiPaths.server.ts
Comment thread apps/webapp/app/services/deploymentApiPaths.server.ts
@myftija
myftija merged commit 02de2e6 into main Aug 11, 2026
45 checks passed
@myftija
myftija deleted the feat/deployment-rate-limiter-tri-13144 branch August 11, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants