-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix(aci milestone 3): check for resolution condition in metric detector validator #102922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,13 @@ def schedule_update_project_config(detector: Detector) -> None: | |
|
|
||
| class MetricIssueComparisonConditionValidator(BaseDataConditionValidator): | ||
| supported_conditions = frozenset( | ||
| (Condition.GREATER, Condition.LESS, Condition.ANOMALY_DETECTION) | ||
| ( | ||
| Condition.GREATER, | ||
| Condition.LESS, | ||
| Condition.GREATER_OR_EQUAL, | ||
| Condition.LESS_OR_EQUAL, | ||
| Condition.ANOMALY_DETECTION, | ||
| ) | ||
| ) | ||
| supported_condition_results = frozenset( | ||
| (DetectorPriorityLevel.HIGH, DetectorPriorityLevel.MEDIUM, DetectorPriorityLevel.OK) | ||
|
|
@@ -132,6 +138,12 @@ def validate_conditions(self, value): | |
| MetricIssueComparisonConditionValidator(data=value, many=True).is_valid( | ||
| raise_exception=True | ||
| ) | ||
| if not any( | ||
| condition["condition_result"] == DetectorPriorityLevel.OK for condition in value | ||
| ) and not any(condition["type"] == Condition.ANOMALY_DETECTION for condition in value): | ||
| raise serializers.ValidationError( | ||
| "Resolution condition required for metric issue detector." | ||
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Validation bypass: raw input used after validationThe |
||
| return value | ||
|
|
||
|
|
||
|
|
@@ -146,7 +158,7 @@ def validate(self, attrs): | |
|
|
||
| if "condition_group" in attrs: | ||
| conditions = attrs.get("condition_group", {}).get("conditions") | ||
| if len(conditions) > 2: | ||
| if len(conditions) > 3: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. high, medium, ok |
||
| raise serializers.ValidationError("Too many conditions") | ||
|
|
||
| return attrs | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this and the condition below it are used for resolution