You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Repeated integration DELETE runs uninstall() again and can remove a shared install from another org #129229
OrganizationIntegrationDetailsEndpoint.delete (src/sentry/integrations/api/endpoints/organization_integration_details.py) calls the provider's uninstall() hook on every request, even when the OrganizationIntegration is already PENDING_DELETION:
The org integration lookup doesn't filter on status, so a second DELETE finds the pending row.
Only after that, the status__in=[ACTIVE, DISABLED] guard prevents a second ScheduledDeletion and audit entry.
The endpoint returns 204 either way.
The guard covers the database side effects, but not the external one.
Impact
Discord's and Cursor Origin's uninstall() only remove the external install when they think the current org is the last one using it, and they skip rows that are PENDING_DELETION / DELETION_IN_PROGRESS when counting.
With orgs A and B sharing one Discord server:
First DELETE from A: A's row is still active, the hook counts A and B, sees 2 installs and does nothing. A's row becomes pending.
Second DELETE from A (client retry, double click, replayed request): the hook now counts only B, sees 1 install, and calls leave_guild. The Sentry bot leaves the server that org B still uses.
Cursor Origin has the same pattern and would call delete_installation on an installation another org still uses to mint tokens.
Reproduced locally with a regression test on master: the second DELETE triggers one leave_guild call.
Fix
Return 204 before calling uninstall() when the org integration is already PENDING_DELETION or DELETION_IN_PROGRESS. The first DELETE keeps its current ordering (uninstall runs while the row is still active, so the hooks count it).
Notes
Concurrent first DELETEs can still both pass the check before either commits the status change. That window is narrow; closing it would mean holding a row lock across the external uninstall call, which this fix doesn't do.
Activity
linear-code commentedon Oct 29, 2026
ENG-8932
fix(integrations): Skip uninstall on repeated integration DELETE (get…