-
Notifications
You must be signed in to change notification settings - Fork 612
[Bug] Add unit tests and fix Alert Suppression schema validation for ThresholdQueryRuleData #5196
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
Merged
eric-forte-elastic
merged 6 commits into
main
from
5195-bug-dac-alertsuppressionmapping-field-not-correctly-registered-as-optional-with-marshmallow-dataclass861
Oct 9, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Enhancement - GuidelinesThese guidelines serve as a reminder set of considerations when addressing adding a new schema feature to the code. Documentation and Context
Code Standards and Practices
Testing
Additional Schema Related Checks
|
Mikaayenson
approved these changes
Oct 9, 2025
w0rk3r
approved these changes
Oct 9, 2025
w0rk3r
reviewed
Oct 9, 2025
Comment on lines
+1077
to
+1082
| # ThresholdQueryRuleData needs to be first in this union to handle cases where there is ambiguity between | ||
| # ThresholdAlertSuppression and AlertSuppressionMapping. Since AlertSuppressionMapping has duration as an | ||
| # optional field, ThresholdAlertSuppression objects can be mistakenly loaded as an AlertSuppressionMapping | ||
| # object with group_by and missing_fields_strategy as missing parameters, resulting in an error. | ||
| # Checking the type against ThresholdQueryRuleData first in the union prevent this from occurring. | ||
| # Please also keep issue 1141 in mind when handling union schemas. |
Contributor
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.
👍🏼
Contributor
Author
|
Make test cli and make test remote CLI completed successfully: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request
Issue link(s):
Resolves #5195
Summary - What I changed
See the linked issue above for more info, but ultimately we need to update AlertSuppression support cases that either just have a duration, or have both a group_by and missing_fields strategy, or all all three (as indicator match rules can have).
This cannot be adequately handled via a
validates_schemamethod in AlertSuppressionMapping as the rule type is not know here which would be required to adequetly enforce that the only rule type that can have only duration is ThresholdQueryRuleData. As such, this needs to be handled through the separate dataclasses we already have (See issue summary for more context).Use the following ndjson file for testing with example rules with all of the different variations of valid alert suppression configurations in Kibana.
test_alert_suppression_all.ndjson.txt
How To Test
For testing, use the new unit tests to check for the various valid combinations of alert suppression with different rule types.
Checklist
bug,enhancement,schema,maintenance,Rule: New,Rule: Deprecation,Rule: Tuning,Hunt: New, orHunt: Tuningso guidelines can be generatedmeta:rapid-mergelabel if planning to merge within 24 hoursContributor checklist