Add rate limit to billable member delete API

What does this MR do and why?

Adds the members_delete rate limit to DELETE /groups/:id/billable_members/:user_id. This is the same limit that DELETE /groups/:id/members/:user_id already uses.

  • The limit is scoped to the group and the current user. It's checked after the group lookup, so a group that doesn't exist or that the user can't see still returns 404.
  • A request over the limit returns 429 Too Many Requests with a Retry-After header, and the user isn't scheduled for removal.
  • Admins control the limit with the existing Members API rate limits setting (members_delete_limit, 60 per minute by default). Both endpoints count toward it, so no new setting is needed.
  • SCIM deprovisioning and dormant member removal call Members::ScheduleDeletionService directly, not through this endpoint, so they aren't affected.
  • Docs: adds a note to the billable member API section, lists both endpoints on the rate limits page, and fixes the settings section name there to match the UI.

References

Screenshots or screen recordings

Tested on a local GDK with Members API rate limits set to 1, so the second request in each pair is over the limit. The curl output is filtered to the status line, Retry-After and the body.

Setup:

638935-01-setup-members-api-rate-limit-1.png

Before After
638935-02-before-master-both-204.png 638935-03-after-branch-204-then-429.png

The user from the rejected request isn't scheduled for removal:

638935-04-after-rejected-user-not-scheduled.png

New specs:

638935-05-after-new-specs-pass.png

How to set up and validate locally

  1. In Admin > Settings > Network, expand Members API rate limits, set the limit to 1, and save.

  2. As the owner of a top-level group, remove two different users in a row:

    curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" \
      --url "http://127.0.0.1:3000/api/v4/groups/<group_id>/billable_members/<user_id>"
  3. The first request returns 204. The second returns 429 with Retry-After: 60, and that user isn't scheduled for removal.

  4. Set the limit back to 60.

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 Shashank Mukkoti

Merge request reports

Loading
Loading