octokit.net icon indicating copy to clipboard operation
octokit.net copied to clipboard

GetLastApiInfo() returns only zero's after a call?

Open StefH opened this issue 5 years ago • 3 comments

Using Octokit version 0.32.0 to 0.40.0, the GetLastApiInfo() returns 0 values ?

For an example project : see https://github.com/StefH/OctokitExample/tree/master/src

See also https://github.com/octokit/octokit.net/issues/1711

StefH avatar Mar 26 '20 09:03 StefH

@StefH thanks for the report. I've isolated this to how headers are returned when an unauthenticated request is made.

This tests shows how the headers for rate-limiting information differ:

$ curl -s -o /dev/null -D -  https://api.github.com/rate_limit | grep "X-Rate"
X-Ratelimit-Limit: 60
X-Ratelimit-Remaining: 60
X-Ratelimit-Reset: 1585235264
$ curl -s -o /dev/null -H "Authorization: token $OCTOKIT_OAUTHTOKEN" -D - https://api.github.com/rate_limit | grep "X-Rate"
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 5000
X-RateLimit-Reset: 1585235267
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset

Note the Ratelimit returned from the first command - the lower-case l here is why we are unable to parse the numbers from the header.

As a workaround, I recommend setting the Credentials property on your GitHubClient to perform an authenticated request. This will also give you a larger number of API calls to work with - unauthenticated requests are limited to 60 requests per hour.

I need to investigate the root cause of this on our end, and will close this out when it's been resolved.

shiftkey avatar Mar 28 '20 19:03 shiftkey

Ok. This seems like a bug in the API from GitHub...

I currently use octokit library in https://github.com/StefH/GitHubReleaseNotes

This is currently just using the free unauthenticated API.

Is it a good idea to include an authenticated call in an public application which is used by multiple people at the same time? How is the rate limit calculated? Is this 5000 per system/user or 5000 in total?

An another request: if possible retarget .net framework 4.5.2 in octokit because this is missing from the latest?

StefH avatar Mar 28 '20 19:03 StefH

How is the rate limit calculated? Is this 5000 per system/user or 5000 in total?

Essentially 5000 per user, but the documentation has more information about the specifics.

Is it a good idea to include an authenticated call in an public application which is used by multiple people at the same time?

Yes. 60 requests/hour may not allow much usage before rate-limiting is enforced.

I see you have a documented --token parameter for private repositories - if users are seeing themselves get rate-limited then they can add this to get the increased API request count (for public or private repositories).

An another request: if possible retarget .net framework 4.5.2 in octokit because this is missing from the latest?

This deprecation was flagged back in 0.35 in October last year because upstream dependencies had dropped these versions:

As part of keeping up with current target frameworks in .NET, we will be deprecating net45 and netstandard1.1 targets in a future release. This update adds net46 and netstandard2.0 outputs which will become the new baseline, so please test them out in your projects and report any issues you encounter.

In February (so 5ish months later) v0.41 dropped the older versions:

Octokit and Octokit.Reactive now have a minimum target of net46 and netstandard2.0 to keep up with the minimum supported versions of Reactive Extensions for .NET. v0.40.0 is the last version that targets net45 or netstandard1.0, but you will need to upgrade your projects to continue to get further updates and fixes.

To continue to receive updates you will need to retarget net46. I'm not sure if there's a specific dependency that is blocking you from doing this upgrade, but I'd been falling behind keeping up with System.Reactive which forced me to plan for this deprecation.

shiftkey avatar Mar 28 '20 20:03 shiftkey

👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

github-actions[bot] avatar Jul 26 '23 01:07 github-actions[bot]