diff --git a/src/sentry/api/helpers/group_index/update.py b/src/sentry/api/helpers/group_index/update.py index 359c3cf275dce5..632ccd9d79cfd9 100644 --- a/src/sentry/api/helpers/group_index/update.py +++ b/src/sentry/api/helpers/group_index/update.py @@ -25,7 +25,7 @@ from sentry.db.models.query import create_or_update from sentry.hybridcloud.rpc import coerce_id_from from sentry.integrations.tasks.kick_off_status_syncs import kick_off_status_syncs -from sentry.issues.grouptype import GroupCategory, get_group_type_by_type_id +from sentry.issues.grouptype import GroupCategory from sentry.issues.ignored import handle_archived_until_escalating, handle_ignored from sentry.issues.merge import MergedGroup, handle_merge from sentry.issues.priority import update_priority @@ -206,12 +206,9 @@ def update_groups( status = result.get("status") res_type = None if "priority" in result: - if any( - not get_group_type_by_type_id(group.type).enable_user_priority_changes - for group in groups - ): + if any(not group.issue_type.enable_user_status_and_priority_changes for group in groups): return Response( - {"detail": "Cannot manually set priority of a metric issue."}, + {"detail": "Cannot manually set priority of one or more issues."}, status=HTTPStatus.BAD_REQUEST, ) @@ -222,6 +219,12 @@ def update_groups( project_lookup=project_lookup, ) if status in ("resolved", "resolvedInNextRelease"): + if any(not group.issue_type.enable_user_status_and_priority_changes for group in groups): + return Response( + {"detail": "Cannot manually resolve one or more issues."}, + status=HTTPStatus.BAD_REQUEST, + ) + try: result, res_type = handle_resolve_in_release( status, diff --git a/src/sentry/incidents/grouptype.py b/src/sentry/incidents/grouptype.py index 67f70fcc8ffd20..560099f4760afc 100644 --- a/src/sentry/incidents/grouptype.py +++ b/src/sentry/incidents/grouptype.py @@ -333,7 +333,7 @@ class MetricIssue(GroupType): enable_escalation_detection = False enable_status_change_workflow_notifications = False enable_workflow_notifications = False - enable_user_priority_changes = False + enable_user_status_and_priority_changes = False detector_settings = DetectorSettings( handler=MetricIssueDetectorHandler, validator=MetricIssueDetectorValidator, diff --git a/src/sentry/issues/grouptype.py b/src/sentry/issues/grouptype.py index 16f9ff7a9f972a..0b4d4880521793 100644 --- a/src/sentry/issues/grouptype.py +++ b/src/sentry/issues/grouptype.py @@ -219,7 +219,7 @@ class GroupType: enable_workflow_notifications = True # Controls whether users are able to manually update the group's priority. - enable_user_priority_changes = True + enable_user_status_and_priority_changes = True # Controls whether Seer automation is always triggered for this group type. always_trigger_seer_automation = False diff --git a/src/sentry/workflow_engine/typings/grouptype.py b/src/sentry/workflow_engine/typings/grouptype.py index d7857a50b2e763..dd4f2107243384 100644 --- a/src/sentry/workflow_engine/typings/grouptype.py +++ b/src/sentry/workflow_engine/typings/grouptype.py @@ -17,4 +17,4 @@ class IssueStreamGroupType(GroupType): enable_escalation_detection = False enable_status_change_workflow_notifications = False enable_workflow_notifications = False - enable_user_priority_changes = False + enable_user_status_and_priority_changes = False diff --git a/tests/sentry/issues/endpoints/test_organization_group_index.py b/tests/sentry/issues/endpoints/test_organization_group_index.py index c4ab1117ff272e..531eb35a3a2b11 100644 --- a/tests/sentry/issues/endpoints/test_organization_group_index.py +++ b/tests/sentry/issues/endpoints/test_organization_group_index.py @@ -4230,7 +4230,7 @@ def test_cannot_update_metric_issue_priority(self) -> None: qs_params={"id": [group.id]}, priority=PriorityLevel.MEDIUM.to_str() ) assert response.status_code == 400 - assert response.data["detail"] == "Cannot manually set priority of a metric issue." + assert response.data["detail"] == "Cannot manually set priority of one or more issues." class GroupDeleteTest(APITestCase, SnubaTestCase): diff --git a/tests/snuba/api/endpoints/test_project_group_index.py b/tests/snuba/api/endpoints/test_project_group_index.py index 69b965ea5126b6..97aa85077b4766 100644 --- a/tests/snuba/api/endpoints/test_project_group_index.py +++ b/tests/snuba/api/endpoints/test_project_group_index.py @@ -12,6 +12,7 @@ from django.conf import settings from django.utils import timezone +from sentry.incidents.grouptype import MetricIssue from sentry.integrations.models.external_issue import ExternalIssue from sentry.integrations.models.organization_integration import OrganizationIntegration from sentry.issues.grouptype import PerformanceSlowDBQueryGroupType @@ -486,6 +487,20 @@ def test_bulk_resolve(self) -> None: assert len(response.data) == 0 + def test_exclude_metric_issue(self) -> None: + self.login_as(user=self.user) + + self.create_group() + self.create_group(type=MetricIssue.type_id) + + response = self.client.put( + f"{self.path}?status=unresolved&query=is:unresolved", + data={"status": "resolved"}, + format="json", + ) + assert response.status_code == 400, response.data + assert response.data["detail"] == "Cannot manually resolve one or more issues." + @patch("sentry.integrations.example.integration.ExampleIntegration.sync_status_outbound") def test_resolve_with_integration(self, mock_sync_status_outbound: MagicMock) -> None: self.login_as(user=self.user)