Skip to content

fix: make installation repository events idempotent#264

Merged
jakharmonika364 merged 1 commit into
Coder-s-OG-s:mainfrom
AbhishekMauryaGEEK:fix/installation-repos-idempotency
Jun 6, 2026
Merged

fix: make installation repository events idempotent#264
jakharmonika364 merged 1 commit into
Coder-s-OG-s:mainfrom
AbhishekMauryaGEEK:fix/installation-repos-idempotency

Conversation

@AbhishekMauryaGEEK

Copy link
Copy Markdown
Contributor

Summary

Makes installation_repositories.added webhook processing idempotent by replacing insert() with upsert().

Related Issue

Closes #262

Type of Change

  • Bug fix
  • Reliability improvement

What Changed?

  • Replaced insert() with upsert() when handling repositories_added events.
  • Added conflict handling on (installation_id, repo_full_name).
  • Added a regression test covering repositories_added webhook processing.

Why?

GitHub may redeliver webhook events. The installation_repositories table uses a composite primary key:

(installation_id, repo_full_name)

Using insert() could cause duplicate-key failures if the same webhook is replayed or redelivered.

Switching to upsert() makes the operation idempotent and aligns this code path with the existing installation creation flow, which already uses upsert() for repository synchronization.

Validation

  • npm run typecheck
  • npm test

Checklist

  • My code follows the project structure and conventions
  • I tested the changes locally
  • Added a regression test for the modified behavior
  • No breaking changes introduced

@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

@AbhishekMauryaGEEK is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mergeship Ready Ready Preview, Comment Jun 6, 2026 9:47am

@jakharmonika364 jakharmonika364 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Excellent improvements to security, concurrency guards, and webhook replay idempotency.

@jakharmonika364 jakharmonika364 added level:advanced Advanced level difficulty quality:exceptional Exceptional quality contribution type:bug Bug fix gssoc:approved Approved by GSSOC admin mentor:Ayush-Patel-56 Replace Ayush-Patel-56 with mentor's GitHub handle to credit them labels Jun 6, 2026
@jakharmonika364 jakharmonika364 merged commit 5af2f56 into Coder-s-OG-s:main Jun 6, 2026
5 checks passed
@AbhishekMauryaGEEK AbhishekMauryaGEEK deleted the fix/installation-repos-idempotency branch June 6, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved by GSSOC admin level:advanced Advanced level difficulty mentor:Ayush-Patel-56 Replace Ayush-Patel-56 with mentor's GitHub handle to credit them quality:exceptional Exceptional quality contribution type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: installation_repositories.added webhook handler is not idempotent

2 participants