Skip to content

Commit a1c5287

Browse files
authored
fix(aci): Reject condition_group for error detectors (#96602)
1 parent 4a75aa1 commit a1c5287

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/sentry/workflow_engine/endpoints/validators/base/detector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class BaseDetectorTypeValidator(CamelSnakeSerializer):
3939
config = serializers.JSONField(default=dict)
4040
owner = ActorField(required=False, allow_null=True)
4141
enabled = serializers.BooleanField(required=False)
42+
condition_group = BaseDataConditionGroupValidator(required=False)
4243

4344
def validate_type(self, value: str) -> builtins.type[GroupType]:
4445
type = grouptype.registry.get_by_slug(value)

src/sentry/workflow_engine/endpoints/validators/error_detector.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ def validate_type(self, value: str):
2525

2626
return type
2727

28+
def validate_condition_group(self, value):
29+
if value is not None:
30+
raise serializers.ValidationError(
31+
"Condition group is not supported for error detectors"
32+
)
33+
return value
34+
2835
def validate_fingerprinting_rules(self, value):
2936
if not value:
3037
return value

tests/sentry/workflow_engine/detectors/test_error_detector.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,28 @@ def test_invalid_resolve_duration(self) -> None:
8282
ErrorDetail(string="Resolve age must be a non-negative number", code="invalid")
8383
]
8484

85+
def test_invalid_condition_group(self) -> None:
86+
data = {
87+
**self.valid_data,
88+
"condition_group": {
89+
"logic_type": "any",
90+
"conditions": [
91+
{
92+
"type": "eq",
93+
"comparison": 100,
94+
"condition_result": "high",
95+
}
96+
],
97+
},
98+
}
99+
validator = ErrorDetectorValidator(data=data, context=self.context)
100+
assert not validator.is_valid()
101+
assert validator.errors.get("conditionGroup") == [
102+
ErrorDetail(
103+
string="Condition group is not supported for error detectors", code="invalid"
104+
)
105+
]
106+
85107
def test_update_existing_with_valid_data(self) -> None:
86108
data = {**self.valid_data, "name": "Updated Detector"}
87109
validator = ErrorDetectorValidator(

0 commit comments

Comments
 (0)