Skip to content

Commit f4d2114

Browse files
committed
fix: Filter out groups that are pending deletion/merge from by_qualified_short_id (SEN-849)
We had an issue where we could create grouplinks for groups that are pending deletion/merge/. The invalid grouplinks prevented us from being able to deploy sentry. I'm adding this in `by_qualified_short_id` because I don't think there are really valid conditions where we'd want to fetch a group that will soon be removed by short id. I feel that ideally we'd actually enforce this at the manager level for all groups, and then have a separate manager for accessing deleted groups in the few cases where we need them, but probably not happening today.
1 parent 6d249e6 commit f4d2114

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/sentry/models/group.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ def by_qualified_short_id(self, organization_id, short_id):
130130
raise ValueError()
131131
except ValueError:
132132
raise Group.DoesNotExist()
133-
return Group.objects.get(
133+
return Group.objects.exclude(status__in=[
134+
GroupStatus.PENDING_DELETION,
135+
GroupStatus.DELETION_IN_PROGRESS,
136+
GroupStatus.PENDING_MERGE,
137+
]).get(
134138
project__organization=organization_id,
135139
project__slug=slug,
136140
short_id=short_id,

tests/sentry/models/test_group.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ def test_qualified_share_id(self):
166166

167167
assert group2 == group
168168

169+
group.update(status=GroupStatus.PENDING_DELETION)
170+
with self.assertRaises(Group.DoesNotExist):
171+
Group.objects.by_qualified_short_id(group.organization.id, short_id)
172+
169173
def test_first_last_release(self):
170174
project = self.create_project()
171175
release = Release.objects.create(

0 commit comments

Comments
 (0)