Repository navigation
Expose Management API rate limit info via a client callback - #774
Open
ProdigyTom wants to merge 11 commits into
Open
ProdigyTom wants to merge 11 commits into
ProdigyTom wants to merge 11 commits into
Conversation
Contributor
|
@ProdigyTom I can see some merge conflicts. Can you please resolve them? Post that I can take a look |
6 of 8 tasks
ProdigyTom
force-pushed
the
feat/expose-rate-limit-data
branch
from
September 2, 2026 13:39
1943366 to
f119645
Compare
Author
|
@kishore7snehil my original change was against v5 and after the change to v6 I wasn't really able to resolve my merge conflicts in a way that still solved our problem. The rate limiting information gets dropped earlier in some generated code. So I wound up going a slightly different direction. let me know if it makes sense |
Exposes Auth0's rate limit info (x-ratelimit-limit / -remaining / -reset) from every Management API response via an opt-in callback, so callers can monitor how close they are to the limit (per auth0#606). - Add Auth0::Internal::Http::RateLimit (limit/remaining/reset; blank and non-numeric header values become nil rather than 0) - RawClient gains a rate_limit_handler, invoked in #send after retries on every response; handler errors are swallowed so they can't break a request. #send's return value is unchanged, so generated callers are unaffected. - Wire it through the custom client: Auth0::Client.new(management_rate_limit_handler:) attaches the handler to the management raw client - Unit tests for RateLimit, RawClient#send handler behavior, and client wiring All changes live in fernignored files, so they survive regeneration. Refs auth0#606.
ProdigyTom
force-pushed
the
feat/expose-rate-limit-data
branch
from
September 23, 2026 20:35
f119645 to
df19130
Compare
kishore7snehil
requested changes
Oct 5, 2026
- Notify on every response (inside the retry loop) so intermediate 429s reach the handler, not just the final response - Fail loud if the handler can't be attached to the management raw client (raise) instead of silently no-opping if internals drift - Warn (but still swallow) when a handler raises, so broken monitoring is visible - Extend support to the Authentication API path (HTTPProxy), via a single rate_limit_handler option covering both APIs - RateLimit gains from_http_response (Net::HTTP) and from_headers (RestClient) builders; reset/whitespace parsing pinned - Tests: retried-request notification, token-rebuild re-attach, case-insensitive header lookup, reset garbage/whitespace, Authentication-path handler - Docs: README options row + Rate Limit Monitoring section, EXAMPLES snippet
Auth0::Unsupported is part of the HTTP error family; a failure to attach the rate limit handler is a configuration/internals issue, not an HTTP failure, so a plain Auth0::Exception is a better fit.
kishore7snehil
requested changes
Oct 14, 2026
- Validate rate_limit_handler responds to #call at build time (fail once up front instead of warning on every response) - Extract RateLimit.deliver so header parsing happens outside the handler rescue (a parsing bug is no longer misattributed to the handler) and the notify logic/comment is no longer duplicated across the two HTTP paths - Stop advertising the internal RateLimit class in docs; document the contract (responds to #limit/#remaining/#reset) instead - Note the handler is Auth0::Client-only and that validate_id_token's JWKS fetch is not reported; give Rate Limit Monitoring its own EXAMPLES section - Docs/style: trim comments, split run-on sentences, add @raise/@param/@return, shorten the README options row, unbold mid-sentence text - Tests: Authentication path now uses webmock with a real response; add from_headers(nil), RateLimit.deliver, and non-callable-handler cases; move the proxy test out of test/unit/mixins into test/unit
- Attach the handler before caching the management client, so a failed attach doesn't leave a handler-less management cached (next call re-attempts) - Guard the Authentication-path notify against a nil response (call returns nil on e.g. a dropped connection) - Split a remaining semicolon-joined sentence in the README - Tests: cover the incompatible-raw-client raise and the no-cache-on-failure behavior; add Authentication-path retry (429s) and handler-raises cases; assert the warning (and stop leaking "boom" into test output)
Matches the reviewer's suggestion and names the actual failure mode (call returns nil for some errors) rather than a broader respond_to? guard.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Exposes Auth0's rate-limit information (
x-ratelimit-limit/-remaining/-reset) from every Management and Authentication API response, via an opt-in handler, so callers can monitor how close they are to the limit (the ask in #606).Auth0::Internal::Http::RateLimit— value object (limit,remainingas Integers;resetas a UTCTime). Blank/non-numeric header values becomenil(never a misleading0). Two builders:from_http_response(Management/RawClient,Net::HTTP) andfrom_headers(Authentication/HTTPProxy, RestClient).rate_limit_handleroption onAuth0::Client, invoked with the parsedRateLimitafter every response on both API paths.429s that trigger an automatic retry, so a handler watchingremainingsees the point where it ran out.warned (so broken monitoring is visible) but never breaks a request.lib/auth0/internal/**,lib/auth0/mixins/**,lib/auth0/auth_client.rb), so they survive regeneration.References
Testing
Unit tests under
test/unit/cover header parsing (symbol/dashed/mixed-case keys,0vs blank/non-numeric, reset + whitespace), notification on every response across a retried request, the handler error being swallowed, the Authentication-API path, and the client wiring (including re-attach after a token-triggered rebuild). Fullrake testpasses locally with no failures.Checklist