Skip to content

fix: revoke stale per-repo grants (#874) - #879

Open
ionfwsrijan wants to merge 1 commit into
Coder-s-OG-s:mainfrom
ionfwsrijan:fix/issue-874-stale-repo-grant-revocation
Open

fix: revoke stale per-repo grants (#874)#879
ionfwsrijan wants to merge 1 commit into
Coder-s-OG-s:mainfrom
ionfwsrijan:fix/issue-874-stale-repo-grant-revocation

Conversation

@ionfwsrijan

Copy link
Copy Markdown
Contributor

Problem

Per-repo grants were only reconciled when a repo already had a grant, so stale installation_user_repos rows (revoked access, removed members) were never deleted ? leading to phantom repository access and stale grants.

Fix

  • New pure reconcileRepoGrants(existing, proposed) diff returns { toUpsert, toDelete } and runs unconditionally.
  • Stale repo-grant rows are deleted even when the proposed set is empty (all existing rows become stale), decoupled from the highestRepoGrant gate that still controls junction pushes.

Files changed

  • src/lib/maintainer/discover.ts
  • src/inngest/functions/maintainer-discover.ts

Testing

  • Full MergeShip suite passes.
  • Tests cover unconditional reconciliation, empty-proposed deletion, and unchanged-grant no-ops.

Closes #874

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@ionfwsrijan 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.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Hey @ionfwsrijan

You have 7 open PRs right now. The limit is 3 at a time.

Please get your existing PRs merged or closed before opening new ones:

This PR will remain open but won't be reviewed until you're under the limit. See our Contributing Guidelines for details.

@ionfwsrijan

Copy link
Copy Markdown
Contributor Author

@jakharmonika364 @Soumya-codr Please review this

@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.

The diff-computation logic (reconcileRepoGrants) is correct and well tested, but the write side has a real bug: swap the installation_user_repos .insert(...) for .upsert(..., { onConflict: 'installation_id,user_id,repo_full_name' }) so permission-level changes on already-granted repos actually apply instead of silently failing and leaving stale grants in place - otherwise this PR trades one stale-grant bug for another.

@jakharmonika364 jakharmonika364 added the Needs author reply Author need to reply label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs author reply Author need to reply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Revoked per-repo maintainer grants are never cleaned up — installation_user_repos rows persist forever after a collaborator is demoted

2 participants