fix(api): don't double-run webhook side effects on a concurrent duplicate#355
fix(api): don't double-run webhook side effects on a concurrent duplicate#355cavidelizade wants to merge 1 commit into
Conversation
…cate Webhook dedup was a check-then-act: ExistsByDeliveryID then Create. Two concurrent deliveries of the same event both pass the exists check; one Create wins and the other fails the unique delivery_id constraint. That error was only logged, so the losing racer fell through to dispatch and ran the side effects again (duplicate bot comments, duplicate or oscillating state changes). Treat a duplicate-key error from Create as "already processed" and return without dispatching. Closes Devlaner#332 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Webhook deduplication was a check-then-act:
ExistsByDeliveryIDthenCreate. Two concurrent deliveries of the same GitHub event both pass the exists check; oneCreatewins and the other fails the uniquedelivery_idconstraint. That error was only logged, so the losing racer fell through todispatchand ran the side effects a second time, giving duplicate bot comments and duplicate or oscillating state changes.Linked issues
Closes #332
Type of change
fix:)Surface
apps/api/)What changed
Treat a duplicate-key error from
Create(gorm.ErrDuplicatedKey, already used elsewhere withTranslateErroron) as "already processed" and return before dispatching. Sequential redeliveries were already short-circuited by the exists check; this closes the concurrent window.Test plan
go build,go vet,go test ./...greenAI assistance
Claude Code (Opus 4.8), commits carry aCo-Authored-By:trailer