Skip to content

Add Lifecycle Cleanup for GitHub App Uninstallation#704

Open
pavsoss wants to merge 1 commit into
Coder-s-OG-s:mainfrom
pavsoss:feat-installation-cleanup
Open

Add Lifecycle Cleanup for GitHub App Uninstallation#704
pavsoss wants to merge 1 commit into
Coder-s-OG-s:mainfrom
pavsoss:feat-installation-cleanup

Conversation

@pavsoss

@pavsoss pavsoss commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds lifecycle cleanup handling for GitHub App uninstallation.

When an installation is removed, MergeShip now marks it as uninstalled, cleans up installation-scoped derived state, and prevents PR backfill jobs from continuing to process the removed installation.

The core installation record is preserved to retain historical audit context.

Changes Made

Uninstallation Cleanup

Updated process-installation-event.ts to:

  • Mark the installation with uninstalled_at before cleanup begins.
  • Sequentially remove derived installation state from:
    • installation_repositories
    • github_installation_users
    • installation_user_repos
    • installation_settings
    • org_communities
    • repo_sync_cursors
  • Explicitly check Supabase mutation errors.
  • Throw on cleanup failures so Inngest can retry the operation.
  • Keep cleanup idempotent across repeated executions.

Backfill Safety

Updated pr-backfill.ts to verify that an installation is still active before processing.

The guard is applied to both:

  • installation-wide backfills
  • single-repository backfills

Uninstalled or missing installations are safely skipped, while database lookup failures are surfaced so the job can retry.

Historical Data Preservation

The github_installations row is not hard-deleted.

Instead, uninstalled_at is used to represent the installation lifecycle state, preserving the installation record and its historical audit context.

Tests

Expanded coverage for:

  • marking an installation as uninstalled before cleanup
  • derived-table cleanup
  • cleanup failure handling
  • idempotent retry behavior
  • installation-wide backfill skips
  • single-repository backfill skips
  • database lookup error propagation

Closes #700

@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] - Add lifecycle cleanup handling when a GitHub App installation is uninstalled

1 participant