Repository: getsentry/sentry

Issue:
Unable to edit WHEN conditions from issue alert
### Environment

SaaS (https://sentry.io/)

### Steps to Reproduce

1. Create an issue alert with a few WHEN conditions
2. Save it
3. Go to the Alert details page
4. Click on Edit rule
5. Delete all the WHEN conditions
6. Click on Save
7. When you're back to the Alert details page, the WHEN conditions are still there, and the "Updated alert rule" message appears

### Expected Result

The users should be able to edit the alert rules

### Actual Result

The alert rule stays the same after editing

### Product Area

Alerts

### Link

_No response_

### DSN

_No response_

### Version

_No response_


Discussion:
Assigning to @getsentry/support for [routing](https://open.sentry.io/triage/#2-route) ⏲️
Routing to @getsentry/product-owners-alerts for [triage](https://develop.sentry.dev/processing-tickets/#3-triage) ⏲️

Resolving patch:
diff --git a/src/sentry/mediators/project_rules/updater.py b/src/sentry/mediators/project_rules/updater.py
--- a/src/sentry/mediators/project_rules/updater.py
+++ b/src/sentry/mediators/project_rules/updater.py
@@ -60,8 +60,7 @@ def _update_filter_match(self):
             self.rule.data["filter_match"] = self.filter_match
 
     def _update_conditions(self):
-        if self.conditions:
-            self.rule.data["conditions"] = self.conditions
+        self.rule.data["conditions"] = self.conditions or []
 
     def _update_frequency(self):
         if self.frequency:


Test patch:
diff --git a/tests/sentry/api/endpoints/test_project_rule_details.py b/tests/sentry/api/endpoints/test_project_rule_details.py
--- a/tests/sentry/api/endpoints/test_project_rule_details.py
+++ b/tests/sentry/api/endpoints/test_project_rule_details.py
@@ -405,6 +405,42 @@ def test_update_name(self):
         )
         assert_rule_from_payload(self.rule, payload)
 
+    def test_remove_conditions(self):
+        """Test that you can edit an alert rule to have no conditions (aka fire on every event)"""
+        conditions = [
+            {
+                "id": "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition",
+            }
+        ]
+        actions = [
+            {
+                "targetType": "IssueOwners",
+                "fallthroughType": "ActiveMembers",
+                "id": "sentry.mail.actions.NotifyEmailAction",
+                "targetIdentifier": "",
+            }
+        ]
+        rule = self.create_project_rule(
+            project=self.project,
+            action_match=actions,
+            condition_match=conditions,
+            name="no conditions",
+        )
+        payload = {
+            "name": rule.label,
+            "environment": None,
+            "actionMatch": "all",
+            "filterMatch": "all",
+            "frequency": 30,
+            "conditions": [],
+            "actions": actions,
+        }
+
+        self.get_success_response(
+            self.organization.slug, self.project.slug, rule.id, status_code=200, **payload
+        )
+        assert_rule_from_payload(rule, payload)
+
     def test_update_duplicate_rule(self):
         """Test that if you edit a rule such that it's now the exact duplicate of another rule in the same project
         we do not allow it"""