auth0 / auth0-java

Java client library for the Auth0 platform
https://auth0.com
MIT License
286 stars 131 forks source link

RateLimitException contains wrong reset/limit and remaining information #527

Closed alexz75 closed 1 year ago

alexz75 commented 1 year ago

In case RateLimitException thrown it contains only -1 values for limit, remaing and reset

Running applications using management api to get a big amout of the information from auth0. Getting RateLimitException as expected, but it not contains proper information.

No workaround, cannot retry the requests

I've found that the server returns response headers in lower case, but the client is expecting it in different form (BaseRequest):

private RateLimitException createRateLimitException(Auth0HttpResponse response) {
        // -1 as default value if the header could not be found.
        long limit = Long.parseLong(response.getHeader("X-RateLimit-Limit", "-1"));
        long remaining = Long.parseLong(response.getHeader("X-RateLimit-Remaining", "-1"));
        long reset = Long.parseLong(response.getHeader("X-RateLimit-Reset", "-1"));
        return new RateLimitException(limit, remaining, reset);
 }
jimmyjames commented 1 year ago

528 was released in 2.2.0, which should be available in maven central shortly.