Skip to content

fix(integrations): Keep shared external issues in the old org on project transfer - #126319

Open
vaind wants to merge 3 commits into
masterfrom
ivan/scope-external-issue-group-lookup-review
Open

vaind wants to merge 3 commits into
masterfrom
ivan/scope-external-issue-group-lookup-review

Conversation

@vaind

@vaind vaind commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

When a project moves to another organization, the external issues its groups are linked to (a Jira ticket, a GitHub issue, ...) move with it. The old code moved every such issue record, even when groups in projects that stay behind were linked to the same ticket. Those groups were left pointing at a record owned by the new org. So anything that finds groups or the org through the issue record's org stops reaching them: the Jira issue panel, and inbound status/assignee sync once #126011 scopes that lookup by org (Bugbot flagged it there).

Now, for each issue linked to the moved project:

  • Only this project links it: the record moves to the new org, as before.
  • Groups left behind still link it: the record stays in the old org. A copy is made in the new org, and only the moved project's links point at the copy.
  • The new org already tracks the same ticket: the moved project's links point at that record. Before, this case crashed the transfer on the one-record-per-org-and-ticket uniqueness rule. The old org's record is deleted if nothing links it any more.

It also stops a commit link from moving an unrelated issue. Links to commits and to issues store their ids in the same column, so a commit id that happened to match an issue id was enough to move that issue.

Tests cover each case and fail without the fix.

…ect transfer

Transferring a project rewrote organization_id on every ExternalIssue its groups linked, even when groups in projects staying behind linked the same issue. Those groups then pointed at a row owned by another org, so anything resolving groups or the org through ExternalIssue.organization_id could no longer reach them from the old org.

A shared row now stays put and the moved project's links are repointed to a copy in the new org, or to the new org's existing row for the same issue, which also stops the transfer from violating the (organization, integration_id, key) uniqueness. The lookup now only follows issue links, since commit links store Commit ids in the same linked_id column.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 2, 2026
Comment thread src/sentry/models/project.py Resolved
vaind added 2 commits October 22, 2026 09:41
…-issue-group-lookup-review

# Conflicts:
#	src/sentry/models/project.py
…nged

An org owner can accept a project transfer into the project's current org. With old and new org equal, every linked ExternalIssue matched itself as the new org's existing row, so rows only this project linked were deleted while its GroupLinks still pointed at them. The other org-bound cleanup in transfer_to is already gated on org_changed.
@vaind
vaind marked this pull request as ready for review October 22, 2026 07:42
@vaind
vaind requested review from a team as code owners October 22, 2026 07:42
@vaind
vaind requested a review from kcons October 27, 2026 08:04

This branch has not been deployed

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

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant