github: Make addComment idempotent to prevent duplicate PR comments#225
Open
matias-christensen-skydio wants to merge 1 commit intomainfrom
Open
github: Make addComment idempotent to prevent duplicate PR comments#225matias-christensen-skydio wants to merge 1 commit intomainfrom
matias-christensen-skydio wants to merge 1 commit intomainfrom
Conversation
a05be97 to
c9bd434
Compare
When retrying a mutation after a transient error (5xx or RESOURCE_LIMITS_EXCEEDED), addComment would re-post comments that the server had already created, producing duplicate stack outlines and diff tables on PRs. Move the retry loop from the generic graphql() method into update_pull_requests() where it has context to handle this. Between retry attempts, re-query each PR's comments and convert any already-posted new comments to updateIssueComment (edit) operations. This makes the retry idempotent while preserving retry coverage for all transient GitHub API failures.
c9bd434 to
da62129
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RESOURCE_LIMITS_EXCEEDED) would re-postaddCommentmutations that the server had already applied, producing duplicate stack outline and diff table comments on PRs.graphql()method intoupdate_pull_requests()where it has context to handle idempotency. Between retry attempts, re-queries each PR's comments and converts any already-posted new comments toupdateIssueComment(edit) operations.Test plan
revup uploadon a stack of PRs and verify comments are not duplicatedRevupRequestException(502, {})after the first attempt) and verify the retry re-queries comments and converts adds to edits