From 5e74cf8c4dcc6713b81fcec71aba79e02e1ff9dc Mon Sep 17 00:00:00 2001 From: Richard Roggenkemper Date: Tue, 3 Sep 2024 10:32:39 -0700 Subject: [PATCH 1/4] add back feature flag check --- .../group_index/validators/status_details.py | 6 +++++ .../api/endpoints/test_project_group_index.py | 23 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/sentry/api/helpers/group_index/validators/status_details.py b/src/sentry/api/helpers/group_index/validators/status_details.py index ddc1eed45f3e69..aabd5c7cda190c 100644 --- a/src/sentry/api/helpers/group_index/validators/status_details.py +++ b/src/sentry/api/helpers/group_index/validators/status_details.py @@ -1,5 +1,6 @@ from rest_framework import serializers +from sentry import features from sentry.models.release import Release from . import InCommitValidator @@ -59,6 +60,11 @@ def validate_inNextRelease(self, value: bool) -> "Release": def validate_inUpcomingRelease(self, value: bool) -> "Release": project = self.context["project"] + if not features.has("organizations:resolve-in-upcoming-release", project.organization): + raise serializers.ValidationError( + "Your organization does not have access to this feature." + ) + try: return ( Release.objects.filter(projects=project, organization_id=project.organization_id) diff --git a/tests/snuba/api/endpoints/test_project_group_index.py b/tests/snuba/api/endpoints/test_project_group_index.py index 01557094cf9d75..9694590429576c 100644 --- a/tests/snuba/api/endpoints/test_project_group_index.py +++ b/tests/snuba/api/endpoints/test_project_group_index.py @@ -28,7 +28,7 @@ from sentry.models.release import Release from sentry.silo.base import SiloMode from sentry.testutils.cases import APITestCase, SnubaTestCase -from sentry.testutils.helpers import parse_link_header +from sentry.testutils.helpers import parse_link_header, with_feature from sentry.testutils.helpers.datetime import before_now, iso_format from sentry.testutils.silo import assume_test_silo_mode from sentry.types.activity import ActivityType @@ -868,6 +868,27 @@ def test_set_resolved_in_upcoming_release(self): ) assert activity.data["version"] == "" + def test_upcoming_release_flag_validation(self): + release = Release.objects.create(organization_id=self.project.organization_id, version="a") + release.add_project(self.project) + + group = self.create_group(status=GroupStatus.UNRESOLVED) + + self.login_as(user=self.user) + + url = f"{self.path}?id={group.id}" + response = self.client.put( + url, + data={"status": "resolved", "statusDetails": {"inUpcomingRelease": True}}, + format="json", + ) + assert response.status_code == 400 + assert ( + response.data["statusDetails"]["inUpcomingRelease"][0] + == "Your organization does not have access to this feature." + ) + + @with_feature("organizations:resolve-in-upcoming-release") def test_upcoming_release_release_validation(self): group = self.create_group(status=GroupStatus.UNRESOLVED) From 0ef20bafabfb14d386dca02808c7cfb6d031067d Mon Sep 17 00:00:00 2001 From: Richard Roggenkemper Date: Tue, 3 Sep 2024 10:36:46 -0700 Subject: [PATCH 2/4] add new check to conditional --- src/sentry/models/groupresolution.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sentry/models/groupresolution.py b/src/sentry/models/groupresolution.py index 1dff3f56a970fb..5c17e9bf115697 100644 --- a/src/sentry/models/groupresolution.py +++ b/src/sentry/models/groupresolution.py @@ -144,7 +144,8 @@ def compare_release_dates_for_in_next_release(res_release, res_release_datetime, # We still fallback to the older model if either current_release_version was not set ( # i.e. In all resolved cases except for Resolved in Next Release) or if for whatever # reason the semver/date checks fail (which should not happen!) - if res_type in (None, cls.Type.in_next_release): + # todo(roggenkemper): remove upcoming_release check after we know that no group resolutions have it + if res_type in (None, cls.Type.in_next_release, cls.Type.in_upcoming_release): # Add metric here to ensure that this code branch ever runs given that # clear_expired_resolutions changes the type to `in_release` once a Release instance # is created From 4af683727d31f7e3bbcd99deae5ee1d273d40bc7 Mon Sep 17 00:00:00 2001 From: Richard Roggenkemper Date: Tue, 3 Sep 2024 10:38:14 -0700 Subject: [PATCH 3/4] rm test --- .../api/endpoints/test_project_group_index.py | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/tests/snuba/api/endpoints/test_project_group_index.py b/tests/snuba/api/endpoints/test_project_group_index.py index 9694590429576c..01557094cf9d75 100644 --- a/tests/snuba/api/endpoints/test_project_group_index.py +++ b/tests/snuba/api/endpoints/test_project_group_index.py @@ -28,7 +28,7 @@ from sentry.models.release import Release from sentry.silo.base import SiloMode from sentry.testutils.cases import APITestCase, SnubaTestCase -from sentry.testutils.helpers import parse_link_header, with_feature +from sentry.testutils.helpers import parse_link_header from sentry.testutils.helpers.datetime import before_now, iso_format from sentry.testutils.silo import assume_test_silo_mode from sentry.types.activity import ActivityType @@ -868,27 +868,6 @@ def test_set_resolved_in_upcoming_release(self): ) assert activity.data["version"] == "" - def test_upcoming_release_flag_validation(self): - release = Release.objects.create(organization_id=self.project.organization_id, version="a") - release.add_project(self.project) - - group = self.create_group(status=GroupStatus.UNRESOLVED) - - self.login_as(user=self.user) - - url = f"{self.path}?id={group.id}" - response = self.client.put( - url, - data={"status": "resolved", "statusDetails": {"inUpcomingRelease": True}}, - format="json", - ) - assert response.status_code == 400 - assert ( - response.data["statusDetails"]["inUpcomingRelease"][0] - == "Your organization does not have access to this feature." - ) - - @with_feature("organizations:resolve-in-upcoming-release") def test_upcoming_release_release_validation(self): group = self.create_group(status=GroupStatus.UNRESOLVED) From f5aed3542295f212e95146f57fb16b63e5be12c4 Mon Sep 17 00:00:00 2001 From: Richard Roggenkemper Date: Tue, 3 Sep 2024 10:38:52 -0700 Subject: [PATCH 4/4] rm check --- .../api/helpers/group_index/validators/status_details.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/sentry/api/helpers/group_index/validators/status_details.py b/src/sentry/api/helpers/group_index/validators/status_details.py index aabd5c7cda190c..ddc1eed45f3e69 100644 --- a/src/sentry/api/helpers/group_index/validators/status_details.py +++ b/src/sentry/api/helpers/group_index/validators/status_details.py @@ -1,6 +1,5 @@ from rest_framework import serializers -from sentry import features from sentry.models.release import Release from . import InCommitValidator @@ -60,11 +59,6 @@ def validate_inNextRelease(self, value: bool) -> "Release": def validate_inUpcomingRelease(self, value: bool) -> "Release": project = self.context["project"] - if not features.has("organizations:resolve-in-upcoming-release", project.organization): - raise serializers.ValidationError( - "Your organization does not have access to this feature." - ) - try: return ( Release.objects.filter(projects=project, organization_id=project.organization_id)