Show rate limit errors for billable user preview UI

What does this MR do and why?

  • Surfaces the backend rate limit on gitlabSubscriptionsPreviewBillableUserChange in the UI. Without this, a throttled user sees nothing, and the invite modal lets the invite through without the seat overage check.
  • Covers the three callers: the invite modal, the role dropdown and the member drawer.
  • No user-facing change until the limit is enforced. The rule only logs while preview_billable_user_change_rate_limit is off, which is the default, so the UI never receives a rate_limited error.

Stacked MRs

Order MR What it does
1 !271586 (merged) backend - per-user rate limit on the field, behind preview_billable_user_change_rate_limit
2 This MR frontend - show the rate limit error in the three callers

References

  • Related to: #637060
  • Rollout issue: #640528

Screenshots or screen recordings

Component Screenshot
Invite modal (user) 637060-rate-limit-invite-user
Invite modal (group) 637090-rate-limit-invite-group
Role dropdown 637060-rate-limit-dropdown
Member drawer 637060-rate-limit-drawer

How to set up and validate locally

Setup

  1. Create a test branch pulling in changes from this branch and the related backend changes from !271586 (merged)

  2. Start GDK with SaaS simulation:

    export GITLAB_SIMULATE_SAAS=1; gdk restart
  3. In the Rails console, set the application setting limit to 2

    ApplicationSetting.current.update!(preview_billable_user_change_limit: 2)
  4. In the Rails console, enable the feature flags:

    Feature.enable(:preview_billable_user_change_rate_limit)
    Feature.enable(:show_overage_on_role_promotion)
  5. Use a top-level group with an Ultimate license where you are an Owner. For the invite modal, CDot must be running locally and report the group as eligible for seat reconciliation.

Trigger the rate limit

  1. In GraphiQL, run this query 3 times:

    query {
      group(fullPath: "<ultimate_group_path>") {
        gitlabSubscriptionsPreviewBillableUserChange(addUserIds: [<user_id>], role: DEVELOPER) {
          newBillableUserCount
        }
      }
    }
  2. The third run returns null with the error This endpoint has been requested too many times. Try again later. and extensions.error_type set to rate_limited.

Test each UI below within a minute of the third run. If the limit has reset, run the query 3 times again.

Invite members modal

  1. Go to the group's Manage > Members and select Invite members.
  2. Add a member and select Invite.
  3. Expected: the modal stays open, shows the rate limit error under the member field, and does not send the invite.

Invite a group modal

  1. Go to the group's Manage > Members and select Invite a group.
  2. Add a group and select Invite.
  3. Expected: the modal stays open, shows the rate limit error under the group field, and does not send the invite.

Member drawer

  1. Go to the group's Manage > Members and find a member with the Guest role.
  2. Select Guest to open the Role details drawer.
  3. Select Developer from the Role dropdown, then select Update role.
  4. Expected: the drawer shows the rate limit error in an alert and the role is not changed.

Role dropdown

  1. In the Rails console, disable the drawer so the Role column shows a dropdown:

    Feature.disable(:show_role_details_in_drawer)
  2. Go to the group's Manage > Members and find a member with the Guest role.

  3. Select the Guest dropdown and choose Developer.

  4. Expected: an alert shows the rate limit error and the role goes back to Guest.

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 Sandra To

Merge request reports

Loading
Loading