Convert webhook rate limit feature flags to application settings

What does this MR do and why?

Converts two long-lived ops feature flags into configurable application settings, as proposed in Revisit webhook rate limit feature flags for ap... (#587887 - closed):

New setting Replaces flag Default
web_hook_event_resend_limit web_hook_event_resend_api_endpoint_rate_limit 5
web_hook_test_limit web_hook_test_api_endpoint_rate_limit 5

Both flags were default_enabled: true and gated hardcoded limits of 5 requests/minute. The flag was an on/off switch; the number itself was not configurable.

The new settings live in the rate_limits JSONB column, following the same shape as most existing ApplicationRateLimiter settings (groups_api_limit, users_api_limit_followers, and about 25 others): one integer per limit, 0 disables it, interval hardcoded at 1 minute. Administrators can change them in Admin > Settings > Network > Webhook rate limits or through the application settings API.

The MR has two commits, mirroring the archive_rate_limit conversion (gitlab-org/gitlab@caff07402f29, gitlab-org/gitlab@02698faf3a8f):

  1. Add the settings (no behaviour change): model, JSON schema, visible_attributes, threshold lambdas in ApplicationRateLimiter and the labkit registry, admin UI section, docs.
  2. Replace the flags: remove the Feature.enabled? guards, delete the flag definitions, backfill migration, spec and docs updates.

Migration

The backfill writes 0 (limit disabled) only for instances that had explicitly disabled a flag with a boolean=false gate, preserving their opt-out. In every other case nothing is written and the default of 5 applies through the JSONB accessor: flags never set (both are default_enabled: true), flags explicitly enabled, and flags with percentage or actor gates. A partial gate on a default-enabled flag means the limit was mostly active, so keeping the limit active is the safer fallback.

Checked via chatops on 2026-07-13: neither flag is set on GitLab.com, so the migration writes nothing there and the default of 5 applies.

Behaviour nuance

The controller paths (Projects::HooksController, WebHooks::HookLogActions, Groups::HooksController in EE) already called check_rate_limit! with the same keys and no flag guard. Disabling the flag only lifted the limit on the API endpoints; setting the limit to 0 now disables it everywhere, UI included. Instances that disabled the flag were presumably after exactly that, so this is a consistency improvement.

The docs previously described the resend limit as "for each project webhook and authenticated user", but the scope is [hook.parent, current_user]: all webhooks in the same project or group share the counter. The updated docs use the corrected wording.

References

Screenshots or screen recordings

Before After
No webhook section on the Network settings page image

How to set up and validate locally

  1. Open Admin > Settings > Network and expand Webhook rate limits. Both fields default to 5.

  2. In a project with a webhook, trigger a test (Settings > Webhooks > Test) six times within a minute. The sixth attempt is rate limited.

  3. Set Maximum webhook test requests allowed per minute on a group or project for each user to 0, save, and repeat. No rate limiting occurs.

  4. Verify the API surface:

    curl --request PUT --header "PRIVATE-TOKEN: $TOKEN" \
      "http://gdk.test:3000/api/v4/application/settings?web_hook_test_limit=2"
  5. Migration: bundle exec rails db:migrate:down:main VERSION=20260713023000 && bundle exec rails db:migrate:up:main VERSION=20260713023000

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist.

Edited by Thiago Figueiró

Merge request reports

Loading
Loading