WIP: fix: reviews may be ahead of timeline #138
Reference in New Issue
Block a user
Delete Branch "fix-multiple-reviews-from-the-same-user"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The problem may be caused by unlucky timing when a review is submitted right after the bot has read the timeline of some PR.
So the bot sees that all reviews are complete, but the timeline is missing some of entries.
-> The bot thinks that the reviews need to be requested.
Also correctly handle multiple reviews from the same user.
fix: correctly handle multiple reviews from the same userto WIP: fix: correctly handle multiple reviews from the same userWIP: fix: correctly handle multiple reviews from the same userto fix: correctly handle multiple reviews from the same userfix: correctly handle multiple reviews from the same userto fix: reviews may be ahead of timelinece15a61eebto833b679c96@@ -25,4 +30,0 @@rawReviews, err := rf.GetPullRequestReviews(org, repo, no)if err != nil {return nil, err}I think this is correct. The timeline could be behind rawReviews, but those rawReviews that are not on the timeline should be ignored.
If you fetch timeline after reviews, you could end up with reviews on the timeline that do not exist in the fetched reviews.
It is two generals problem. With current state the bot will re-request new review(s) if all reviews have been properly submitted and timeline is missing one or some. The reorder fixes that problem in the tests
Basically, you should end up in same situation. A race condition, ie. you add a review trigger that is not seen in timeline, means that the timeline is modified asynchronously after requests are added and you still have a race condition.
Or am I missing something in this analysis?
If the bot is requesting data here, it should still see that it requested the review already. So, that would be the bug, if it doesn't see review request.
Yes it is the bug. It it looks that the bot checks the reviews for question 'Are there any pending reviews?' and sees answer "No". Then it checks the timeline and sees that some reviews are missing. It makes conclusion that it needs to request more.
ok, I think I understand where the problem is. Let me make a unit test and fix and you can merge that into this pr?
I've pushed my changes along with the test changes from this PR to #142 . Can you please take a look and check that this "race condition" is fixed?
In reality, the problem was that issue timeline was not consistently parsed. The initial version of the Reviews code handled only reviews. Then timeline events were tacked on, but not handled correctly. So you could have scenarios where a requested review could not be seen or in another combination, it could be seen the other way. For example, a pending review that is then revoked but was still seen as pending.
I didn't try to understand the changes, but I tested it quite thoroughly in #149 and I confirm that the problem is fixed as it was appearing quite often.
fix: reviews may be ahead of timelineto WIP: fix: reviews may be ahead of timelineView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.