Repeated integration DELETE runs uninstall() again and can remove a shared install from another org
维护者通常 1 天内回复
评估
调研方向
从 src/sentry/integrations/api/endpoints/organization_integration_details.py 中的 OrganizationIntegrationDetailsEndpoint.delete 开始,追踪 uninstall() 调用前后的状态检查。对于状态已经是 PENDING_DELETION 或 DELETION_IN_PROGRESS 的集成,返回 204,同时保留第一次 DELETE 的顺序。添加或运行一个回归测试,连续发送两次 DELETE,并确认第二次请求不会再次调用 uninstall()。
由索引模型根据 Issue 内容生成。
描述
Problem
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.
integration.get_installation(...).uninstall()runs unconditionally.- Only after that, the
status__in=[ACTIVE, DISABLED]guard prevents a secondScheduledDeletionand 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.
- Found during the endpoint idempotency audit in #128927.
via @BYK.
--
- 主要语言
- Python
- 星标
- 45.7k
- 派生
- 5k
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 655
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
getsentry/sentry 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
getsentry/sentry#129182 · 1 条评论 ·
维护者通常 1 天内回复
-
find_referenced_groups: Fixes-keyword ID list spans newlines, linking wrong issues as fixed可能已有人在做 @CodeAlex52 于 30 天前认领。 未关闭Product Area: Releases Waiting for: Product Owner
难度 2/5 1-3 小时 新手友好度 86/100
getsentry/sentry#125575 · 3 条评论 ·
维护者通常 1 天内回复
-
Cocoa replays hide Logs tab on supported SDK versions可能已有人在做 @Brian-An 于 20 天前认领。 未关闭Bug Cocoa Replays
难度 2/5 1-3 小时 新手友好度 82/100
getsentry/sentry#124217 · 1 条评论 ·
维护者通常 1 天内回复
-
Product Area: Settings - Auth Waiting for: Product Owner
难度 2/5 1-3 小时 新手友好度 86/100
getsentry/sentry#122437 · 6 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
Incorrect Russian translation in django.po可能已有人在做 @nightcityblade 于 17 天前认领。 未关闭Bug Good First Issue Product Area: Settings - Integrations
难度 1/5 1 小时以内 新手友好度 90/100
getsentry/sentry#120651 · 3 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
namespace operations
难度 1/5 1 小时以内 新手友好度 65/100
EclipseFdn/open-vsx.org#15057 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
FinanceFlash/unvibecode#349 ·
-
Mission statement: why this is free, in the README, Why This Exists and the wiki Home可能已有人在做 @ChiefGyk3D 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
ChiefGyk3D/Clouds-Against-Humanity#348 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
vllm-project/vime#508 ·
维护者通常 4 天内回复