Implement an abuse handler#289
Conversation
| // Check to see whether we hit a 403, and the message indicates the | ||
| // abuse handler (occurs on too many concurrent requests) | ||
| if (responseCode == HttpURLConnection.HTTP_FORBIDDEN && | ||
| errorString.contains("You have triggered an abuse detection mechanism.")) { |
There was a problem hiding this comment.
@kohsuke This is the only bit I'm not totally sure about. The best bit would be to just be able to check for 403, but I'm not sure whether 403 happens in more circumstances than just API abuse. There wasn't anything else in the header indicating abuse (though maybe I could just check for Retry-After)
Additionally, I imagine that there isn't a way to get a localized error string here, but if there was the check would be broken. Thoughts?
There was a problem hiding this comment.
My 2 cents:
I'd just check for status code and retry-after, those are the ones that are documented.
The human readable hint/text isn't quite documented.
There was a problem hiding this comment.
Okay, yeah I think you're right.
| InputStream es = wrapStream(uc.getErrorStream()); | ||
| try { | ||
| if (es!=null) { | ||
| String errorString = IOUtils.toString(es, "UTF-8"); |
There was a problem hiding this comment.
Dead store to errorString in org.kohsuke.github.Requester.handleApiError(IOException) [org.kohsuke.github.Requester] At Requester.java:[line 579]
If too many requests are made within X amount of time (not the traditional hourly rate limit), github may begin returning 403. Then we should wait for a bit to attempt to access the API again. In this case, we parse out the Retry-After field returned and sleep until that (it's usually 60 seconds)
|
Fixed and moved some code around. |
If too many requests are made within X amount of time (not the traditional hourly rate limit), github may begin returning 403. Then we should wait for a bit to attempt to access the API again. In this case, we parse out the Retry-After field returned and sleep until that (it's usually 60 seconds)
Fixes #285