diff --git a/src/sentry/rules/conditions/event_frequency.py b/src/sentry/rules/conditions/event_frequency.py index f0adcbe6ea5555..5d6b1627ae0a9c 100644 --- a/src/sentry/rules/conditions/event_frequency.py +++ b/src/sentry/rules/conditions/event_frequency.py @@ -166,6 +166,8 @@ def passes(self, event: GroupEvent, state: EventState) -> bool: comparison_type = self.get_option("comparisonType", ComparisonType.COUNT) comparison_interval_option = self.get_option("comparisonInterval", "5m") + if comparison_interval_option == "": + return False comparison_interval = COMPARISON_INTERVALS[comparison_interval_option][1] _, duration = self.intervals[interval] try: diff --git a/tests/snuba/rules/conditions/test_event_frequency.py b/tests/snuba/rules/conditions/test_event_frequency.py index 319a204891c816..0e1f903db7389c 100644 --- a/tests/snuba/rules/conditions/test_event_frequency.py +++ b/tests/snuba/rules/conditions/test_event_frequency.py @@ -292,6 +292,15 @@ def _run_test(self, minutes, data, passes, add_events=False): self.assertDoesNotPass(rule, event, is_new=False) self.assertDoesNotPass(environment_rule, event, is_new=False) + def test_comparison_interval_empty_string(self): + data = { + "interval": "1m", + "value": 16, + "comparisonType": "count", + "comparisonInterval": "", + } + self._run_test(data=data, minutes=1, passes=False) + def test_one_minute_with_events(self): data = {"interval": "1m", "value": 6, "comparisonType": "count", "comparisonInterval": "5m"} self._run_test(data=data, minutes=1, passes=True, add_events=True)