fix: prevent duplicate reviews on open-then-force-push #19
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/duplicate-review-on-force-push"
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?
When a PR is opened and immediately force-pushed (e.g. UI-prompted
rebase), two webhook events fire in quick succession. Both would
independently queue reviews, producing duplicate safety checks.
Two changes fix this:
Add a has_review_in_progress check in _handle_pr_event so the
redundant "synchronized" event is dropped when a review is already
queued.
Move the diff fetch to AFTER the settle delay in _do_review. The
diff was previously fetched before settling, so the review would
use the stale pre-rebase diff even though the settle delay was
designed for exactly this scenario. Now the settle absorbs the
rapid push and the diff fetch picks up the final state.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Automated review by pr-reviewer v0.15.0 | Safety Check | anthropic | tracking id
r-c5a6de-268671This is an AI-generated review and may contain mistakes.
Status: ✅ Completed
✅ Verdict: LGTM — The changes implement a reasonable race condition fix by checking for in-progress reviews and moving diff fetching after the settle delay.
Complexity: moderate
This change addresses a race condition where rapid webhook events could create duplicate reviews. The solution is straightforward:
has_review_in_progress()check early in the event handler to skip redundant eventsThe logic flow is sound - check for duplicates first, settle to absorb rapid changes, then fetch the current diff. Error handling is preserved (empty diff case, comment update failures). No obvious bugs or security issues.