kiwiproject / kiwiproject-changelog

Generates change logs
MIT License
1 stars 0 forks source link

Check rate limits when making HTTP calls to GitHub #173

Closed sleberknight closed 1 month ago

sleberknight commented 2 months ago

Currently we print out (to stdout) the rate limit information (X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset) but don't take any action if, for example, the remaining number of requests is getting "low".

I'm not sure what the "best" thing to do is if the remaining requests is "low", but a start might simply be to print a warning to the console, maybe something like:

⚠️ WARNING: The rate limit 'remaining' is 10 until it resets to 5,000 at 2024-06-09T14:19:30 (about 1 hour from now), which means you can only make 10 more requests before GitHub cuts API access off until the reset time.

We also need to define what "low" means.

sleberknight commented 1 month ago

Rate limit references:

sleberknight commented 1 month ago

In addition to printing a WARNING, if we detect we're at the rate limit, we should not make any more requests. The easiest thing to do is exit with an error and inform the user (it'll most likely be only me) about the problem, tell them the limits and when it resets, and tell them not to run it again until the rate limit resets.