Add per-user rate limit for starring projects

What does this MR do and why?

Adds one limit of 30 requests per minute per user to starring and unstarring a project. Star and unstar share the limit, and the REST API, GraphQL and the web interface all count toward it.

This keeps the limits for these actions consistent across the REST API, GraphQL and the web interface, in line with the existing limits on similar actions.

  • The limit is a staged rule behind the project_star_rate_limit feature flag, which is disabled by default. While the flag is off, requests over the limit are logged but not blocked. With the flag on, they get 429 (or a GraphQL error).
  • The limit is checked after the project is found, so a request for a project the user can't see returns 404 and doesn't count. This matches the other limits in ProjectsController and API::Projects.
  • The rule has a contract entry in config/rate_limits/unowned.yaml, and the docs list it in the non-configurable rate limits.

Production traffic

Star and unstar requests per user per minute on 2026-11-30, from the REST API, the web interface and the setStarStatus GraphQL mutation:

Measure Value
Requests that day 957
Busiest minute for one user 9
Users over 10 in any minute 0
Users over the limit of 30 0

References

  • Rollout issue: #635771
  • Closes #635735

Screenshots or screen recordings

Not applicable, there are no UI changes.

How to set up and validate locally

  1. As a user with access, star and unstar a project (POST /api/v4/projects/:id/star and /unstar) more than 30 times in a minute.

  2. With the flag disabled, the requests succeed. log/api_json.log shows applimiter_project_star:limit_project_stars_by_user_log in rate_limit_state.

  3. Enable the feature flag in the Rails console:

    Feature.enable(:project_star_rate_limit)
  4. Repeat the requests. Requests over the limit receive a 429 response.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Shubham Kumar

Merge request reports

Loading
Loading