-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-Prepare request for retry when using dynamic auth token #1680
Conversation
@emrebasar Also, retry scenarios tend to be quick turnaround. What you're talking about is generally only going to happen related to rate limiting and long waits. Maybe you should add special error scenario for case you want to address. Make it similar to github-api/src/main/java/org/kohsuke/github/GitHubClient.java Lines 629 to 653 in c494891
RetryRequestException .
The detector should check the http error code and prepare a new request. If the authorization string for new request is the same as the current connectorRequest, then you have a valid failure. Otherwise, throw a Make sense? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For most users, preparing the request again is not needed. As noted, we should detect the scenario you describe an update the request only in that case.
Thank you for the feedback. In our use case, rate limiting is the primary cause of retries, and we observe this specific scenario fairly often, though I agree that it might not be the case for majority of the use cases. I will update the code accordingly, and fix the failing tests. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1680 +/- ##
============================================
+ Coverage 80.04% 80.10% +0.06%
- Complexity 2231 2237 +6
============================================
Files 215 215
Lines 6760 6771 +11
Branches 365 367 +2
============================================
+ Hits 5411 5424 +13
+ Misses 1134 1132 -2
Partials 215 215
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All we need now is a test covering the newly added code.
Hi @bitwiseman, I did dive into this, and tried implementing some tests but got stuck at configuring the correct Wiremock behavior. I am planning to continue looking at this, beginning Week 32. How would you like to proceed? Should we close this PR, and open a new one when tests are fixed, or should we keep this one open? |
@emrebasar |
Hi again. I have now returned, and added two tests that verify the behavior. I think there might be some cleanup opportunities in the Wiremock fixtures, but I haven't looked at them in detail yet. I will check that once the CI verifies that the test coverage is at a satisfactory level. |
Currently, a retried request fails if the authentication token expires between retries. This can be a common experience, as GitHub API can throttle a user for up to an hour, which is longer than the lifetime of an authentication token retrieved via the GitHub Application Installation. This commit ensures that a recent token is used in each request by re-creating the connector request for every retry.
Missed javadoc comments on tests. |
Description
Currently, a retried request fails if the authentication token expires between retries. This can be a common experience, as GitHub API can throttle a user for up to an hour, which is longer than the lifetime of an authentication token retrieved via the GitHub Application Installation.
This change ensures that a recent token is used in each request by re-creating the connector request for every retry.
Before submitting a PR:
@link
JavaDoc entries to the relevant documentation on https://docs.github.com/en/rest .mvn -D enable-ci clean install site
locally. If this command doesn't succeed, your change will not pass CI.main
. You will create your PR from that branch.When creating a PR: