Skip to content

Bitbucket Rate Limit Handling #354

@fullben

Description

@fullben

In a project of mine, where I'm using this library, I ended up tripping the Bitbucket request rate limit configured for the user I am using for authenticating with a Bitbucket server.

This happened when calling various paged API endpoints in quick succession. As a result, the Page objects returned by the library methods would suddenly contain Error objects containing information about some JSON parsing issue.

I found determining the source of my issue rather difficult, as the Error objects provided by the Bitbucket REST library only mentioned issues with parsing the response. Only upon checking the Bitbucket server rate limiting options and enabling logging for jclouds, I was able to understand the problem, as a corresponding 429 response will be logged by jclouds whenever the parse issue occurs.

I also understand that modifying the rate limit settings for my Bitbucket user can mitigate this issue, but at the same time I feel like the library should be able to deal a bit more graceful with this scenario.

Expected Behavior

I would either expect there to be a configuration option for dealing with rate limiting (maybe I missed it?), or for the Error object to at least contain some more meaningful information.

Current Behavior

When a rate limit is tripped by the library, the Bitbucket remote responds with a 429 and a JSON object the library does not seem to understand. The corresponding Error object will only provide information about JSON parsing issues:

exceptionName: "com.google.gson.JsonSyntaxException"
message: "Failed to parse output: message=com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 9 path $"

This in turn makes it impossible for me to programmatically identify this error as a rate limit issue.

Context

Calling various endpoints in quick succession for acquiring the permission information for all Bitbucket projects and their repositories on a Bitbucket server instance.

Your Environment

Bitbucket REST client lib version 3.0.2
Bitbucket server instance version 7.6.17

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions