fix: idempotency guard on pull_request.opened (Bug #13)#52
Open
fix: idempotency guard on pull_request.opened (Bug #13)#52
Conversation
Why: QA bug-hunter flagged that pull_request.opened had no
isProcessed/markProcessed gate. Probot retries the webhook ~5 times on
5xx/timeout, replaying enablePullRequestAutoMerge (idempotent on
GitHub's side, but spammy in logs), the AI review (only protected by
the 5-min _reviewTimestamps throttle inside reviewPullRequest), and
the dependabot generation enqueue (creates duplicate task-store
entries with the same key — wasteful and confusing).
What:
- Add `if (deliveryId && isProcessed(deliveryId)) return;` at handler
entry, mirroring the pattern already used by repository.created,
issues.opened, issue_comment.created, and pull_request.closed.
- Add `if (deliveryId) markProcessed(deliveryId);` at handler exit so
subsequent retries hit the dedup gate.
Test plan:
- 2 new tests:
- duplicate delivery short-circuits before reviewPullRequest
- successful delivery records markProcessed
- npm test → 836 pass (was 834)
- npm run lint → clean
Risk: low — same pattern as four sibling handlers.
Note: pull_request.synchronize and pull_request.reopened (added in
PR #50) will need the same guard. Will fold in once #50 lands.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Why
Without this, Probot's webhook retry (~5 attempts on 5xx/timeout) replays `enablePullRequestAutoMerge` (spammy), the AI review (only catches retries within the 5-min `_reviewTimestamps` window), and the dependabot enqueue (creates duplicate task-store entries with the same key).
Test plan
Follow-up
`pull_request.synchronize` and `.reopened` (added in PR #50) need the same guard. Folding that in once #50 lands rather than producing a merge conflict here.
🤖 Generated with Claude Code