🐛 fix(github): Use issues.assignees for inbound assignment sync
#103008
+61
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When switching assignees on a GitHub issue externally (e.g., changing from @billybobthebot to @iamrajjoshi), Sentry would sometimes end up with the wrong assignee or no assignee at all.
Root cause:
GitHub sends two webhooks when switching assignees:
issues.unassigned(for the person being removed)issues.assigned(for the person being added)These webhooks arrive in non-deterministic order, creating a race condition. The old implementation used the assignee field at the root of the webhook payload, which represents the delta (the person being added/removed), not the current state.
Race condition scenarios:
Scenario 1: assigned arrives first, then unassigned
Scenario 2: unassigned arrives first, then assigned
In both cases, there's a window where the wrong assignee gets synced, and depending on timing, the final state could be incorrect.
Solution
Use
issue.assignees(current state after the action) instead of assignee (the delta) when syncing assignments. This ensures both webhooks converge to the same final state regardless of arrival order.After fix:
Note
GitHub supports multiple assignees per issue, but Sentry currently only supports a single assignee per issue, so we take the first user Github returns. It is generally the oldest user to be assigned (based on what I have seen)
Screen.Recording.2025-11-08.at.4.21.02.PM.mov
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.