diff --git a/src/sentry/api/helpers/group_index/update.py b/src/sentry/api/helpers/group_index/update.py index 652e6e75f9b036..7fe278ce47ccc0 100644 --- a/src/sentry/api/helpers/group_index/update.py +++ b/src/sentry/api/helpers/group_index/update.py @@ -136,10 +136,10 @@ def get_current_release_version_of_group(group: Group, follows_semver: bool = Fa """ current_release_version = None if follows_semver: - try: - if not features.has( - "organizations:releases-resolve-next-release-semver-fix", group.project.organization - ): + if not features.has( + "organizations:releases-resolve-next-release-semver-fix", group.project.organization + ): + try: # This sets current_release_version to the latest semver version associated with a group associated_release_id = GroupRelease.objects.filter( project_id=group.project.id, group_id=group.id @@ -150,11 +150,11 @@ def get_current_release_version_of_group(group: Group, follows_semver: bool = Fa .values_list("version", flat=True)[:1] .get() ) - else: - current_release_version = greatest_semver_release(group.project).version + except Release.DoesNotExist: + pass + else: + current_release_version = greatest_semver_release(group.project).version - except Release.DoesNotExist: - pass else: # This sets current_release_version to the most recent release associated with a group # In order to be able to do that, `use_cache` has to be set to False. Otherwise, diff --git a/tests/sentry/issues/endpoints/test_group_details.py b/tests/sentry/issues/endpoints/test_group_details.py index 2d0784abbc92fd..d55114b89d541e 100644 --- a/tests/sentry/issues/endpoints/test_group_details.py +++ b/tests/sentry/issues/endpoints/test_group_details.py @@ -499,6 +499,29 @@ def test_resolved_in_next_release_no_release(self): assert not GroupResolution.objects.filter(group=group).exists() assert response.data["statusDetails"] == {} + @with_feature("organizations:releases-resolve-next-release-semver-fix") + def test_resolved_in_next_release_with_flag_no_release(self): + self.login_as(user=self.user) + + project = self.create_project() + project.flags.has_releases = True + project.save() + event = self.store_event(data={}, project_id=project.id) + group = event.group + assert group is not None + + url = f"/api/0/organizations/{group.organization.slug}/issues/{group.id}/" + response = self.client.put(url, data={"status": "resolvedInNextRelease"}) + assert response.status_code == 200, response.content + + # Refetch from DB to ensure the latest state is fetched + group = Group.objects.get(id=group.id, project=group.project.id) + assert group.status == GroupStatus.RESOLVED + + # no GroupResolution because there is no release + assert not GroupResolution.objects.filter(group=group).exists() + assert response.data["statusDetails"] == {} + def test_snooze_duration(self): group = self.create_group(status=GroupStatus.RESOLVED)