Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Repeated integration DELETE runs uninstall() again and can remove a shared install from another org

未关闭 适合新手
#129,229 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@sentry-junior 已经在做这个了。

开始于 2026年10月29日。

  • #129230 来自 @sentry-junior —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
django, python
领域
api, backend

调研方向

从 src/sentry/integrations/api/endpoints/organization_integration_details.py 中的 OrganizationIntegrationDetailsEndpoint.delete 开始,追踪 uninstall() 调用前后的状态检查。对于状态已经是 PENDING_DELETION 或 DELETION_IN_PROGRESS 的集成,返回 204,同时保留第一次 DELETE 的顺序。添加或运行一个回归测试,连续发送两次 DELETE,并确认第二次请求不会再次调用 uninstall()。

由索引模型根据 Issue 内容生成。

描述

Bug

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:

  1. The org integration lookup doesn't filter on status, so a second DELETE finds the pending row.
  2. integration.get_installation(...).uninstall() runs unconditionally.
  3. Only after that, the status__in=[ACTIVE, DISABLED] guard prevents a second ScheduledDeletion and audit entry.
  4. 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.

--

View Junior Session [Sentry]

主要语言
Python
星标
45.7k
派生
5k
平均合并
1 天 3 小时
30 天内合并 PR
655

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry 的其他 Issue

查看 getsentry/sentry 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。