-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Fix malformed geo alerts call to transformResults
#98094
Fix malformed geo alerts call to transformResults
#98094
Conversation
Pinging @elastic/kibana-gis (Team:Geo) |
@elasticmachine merge upstream |
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.
thx for the forensics on this, and the quick fix.
I would look into if we can add a unit-test on the getGeoContainmentExecutor
. It has some end-2-end glue-code, that is not getting covered right now. This is an opportunity to add some coverage. (it's also the API-extension point of alerting-framework, which helps).
For this test, there's already have an example of a mock on alertInstanceFactory
. I think it would only require one more additional mock for the services.scopedClusterClient.asCurrentUser
esClient. That mock could just return two sample ES-responses: One for the shapes (
kibana/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts
Line 52 in 238791b
const { body: boundaryData }: ApiResponse<Record<string, any>> = await esClient.search({ |
kibana/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts
Line 198 in 238791b
({ body: esResult } = await esClient.search(esQuery)); |
58f5e55
to
38a6a9b
Compare
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.
thx, discussed offline. Unit test looks good, but would mock at more lower-level, the actual search
of the esClient.
along the lines of:
//
alertServices.scopedClusterClient.callAsUser = {
search: (...args) = {
if (isShapeSearchCall) {
return sampleESShapeSearchReturn;
} else if (isTophItsCall) {
return sampleESTopHitsAggReturn;
}
}/
};
^ this should give us more comprehensive "round trip" behavior, thx!
… all under body tag
… use same response files. Misc. clean up
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
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.
code review, thx for adding the comprehensive tests
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This fixes a regression introduced in #93364 where the
body
field was incorrectly appended tocurrentIntervalResults
. This resulted in anundefined
value being passed to the function.To test, set up a normal geo containment alert (see readme). Alerts triggered by both entering and leaving shapes were tested and found working