Use throttled_error_message for the remaining rate limit responses

What does this MR do and why?

Gitlab::ApplicationRateLimiter.throttled_error_message exists so every rate limited response says the same thing, but a number of call sites still built the sentence themselves. Some wrapped it in _() and some did not, which is how wording drifts apart over time and how responses end up inconsistent depending on which endpoint a user happens to hit.

They now all call the helper. The string itself is unchanged and is still translated, because the helper wraps it in _(), so the message users see is identical and the msgid stays in locale/gitlab.pot.

Namespacing follows what each area already does: Gitlab:: under app/, where the surrounding code uses that form, and ::Gitlab:: under lib/ and ee/, where the code is nested and the existing call sites qualify it.

References

The issue lists fifteen files as of August. Two more carry the same literal today and are included here: app/graphql/mutations/organizations/organization_users/create.rb and app/graphql/resolvers/concerns/search/search_rate_limitable.rb.

Differences

Before: seventeen call sites across sixteen files spelled out "This endpoint has been requested too many times. Try again later." themselves, some translated and some not, alongside others that already used the helper. Changing the wording meant finding every copy.

After: every rate limited response draws the message from one place. There is no user visible change: the same sentence is returned, still translated, from the same endpoints.

How to set up and validate locally

grep -rn "This endpoint has been requested too many times" --include=*.rb app/ lib/ ee/ | grep -v _spec.rb

Only lib/gitlab/application_rate_limiter.rb, which defines the helper, should match. The msgid remains in locale/gitlab.pot because that definition still wraps the string in _(), so no regeneration is needed.

RuboCop passes on all sixteen files. Note that Import::GithubService is reformatted rather than only substituted: the shorter line made RuboCop ask for the modifier if form.

Edited by Jeston Singh

Merge request reports

Loading
Loading