Skip to content

Commit f222b77

Browse files
ref: avoid filtering on id=None (#75162)
this technically works at runtime, but django-stubs (imo correctly) flags this as a mistake <!-- Describe your PR here. -->
1 parent 2e4a0d4 commit f222b77

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/sentry/api/endpoints/project_rules.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,12 @@ def find_duplicate(self) -> Rule | None:
236236
"""
237237
Determines whether specified rule already exists, and if it does, returns it.
238238
"""
239-
existing_rules = Rule.objects.exclude(id=self._rule_id).filter(
240-
project__id=self._project_id, status=ObjectStatus.ACTIVE
241-
)
239+
if self._rule_id is None:
240+
all_rules = Rule.objects.all()
241+
else:
242+
all_rules = Rule.objects.exclude(id=self._rule_id)
243+
244+
existing_rules = all_rules.filter(project__id=self._project_id, status=ObjectStatus.ACTIVE)
242245
for existing_rule in existing_rules:
243246
keys_checked = 0
244247
keys_matched = 0

0 commit comments

Comments
 (0)