gofri / go-github-ratelimit

A GoLang HTTP RoundTripper that handles GitHub API secondary rate limits
MIT License
41 stars 13 forks source link

Secondary Rate Limit detector misses message #14

Closed jporzucek closed 1 year ago

jporzucek commented 1 year ago

At the moment Secondary Rate Limit detector checks for single message only which apparently corresponds do POST API requests (content creation). When one hits Secondary Rate Limiter with GET request, the following message is returned by the API: You have exceeded a secondary rate limit. Please wait a few minutes before you try again.

bl-robinson commented 1 year ago

I think this is a bit more or a problem than just this PR handles.

We have just today seen the message from github become You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later. If you reach out to GitHub Support for help, please include the request ID <unique id>.

Is there a better way of dealing with this that is more resilient to the message changing?

gofri commented 1 year ago

Thanks for your comments! I added the message check because of conflicts with the primary rate limit. I tried to follow the API docs but I guess it's too dynamic.

It seems like all the messages start with the same sentence though, so checking for HasPrefix() should work.

I'm on vacation and not gonna have PC access for a few weeks, so please feel free to implement it if it sounds good to you and I'll approve it from my phone.

p.s. @jporzucek sorry for not getting to that earlier, I just missed it

bl-robinson commented 1 year ago

Hey both. I just opened https://github.com/gofri/go-github-ratelimit/pull/16 I had implemented it before you responded @gofri happy for you to use it or not. It just worked for me on our internal tests.

gofri commented 1 year ago

Perfect!

gofri commented 1 year ago

Merged 😄 Thank you both for your contribution!