mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[ResponseOps][Alerting] Elasticsearch query rule type allows SIZE: 0, but flags as error on re-edit (#142225)
* Fixing es query bug * Updating threshold * Adding isNil to another check
This commit is contained in:
parent
c7b742c567
commit
b542f7b520
4 changed files with 42 additions and 4 deletions
|
@ -158,6 +158,20 @@ describe('expression params validation', () => {
|
|||
);
|
||||
});
|
||||
|
||||
test('if size property is 0 should not return error message', () => {
|
||||
const initialParams: EsQueryAlertParams<SearchType.esQuery> = {
|
||||
index: ['test'],
|
||||
esQuery: `{\n \"query\":{\n \"match_all\" : {}\n }\n`,
|
||||
size: 0,
|
||||
timeWindowSize: 1,
|
||||
timeWindowUnit: 's',
|
||||
threshold: [0],
|
||||
timeField: '',
|
||||
excludeHitsFromPreviousRun: true,
|
||||
};
|
||||
expect(validateExpression(initialParams).errors.size.length).toBe(0);
|
||||
});
|
||||
|
||||
test('if size property is > 10000 should return proper error message', () => {
|
||||
const initialParams: EsQueryAlertParams<SearchType.esQuery> = {
|
||||
index: ['test'],
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { defaultsDeep } from 'lodash';
|
||||
import { defaultsDeep, isNil } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { ValidationResult, builtInComparators } from '@kbn/triggers-actions-ui-plugin/public';
|
||||
import { EsQueryAlertParams, ExpressionErrors } from './types';
|
||||
|
@ -63,7 +63,7 @@ export const validateExpression = (ruleParams: EsQueryAlertParams): ValidationRe
|
|||
);
|
||||
}
|
||||
|
||||
if (!size) {
|
||||
if (isNil(size)) {
|
||||
errors.size.push(
|
||||
i18n.translate('xpack.stackAlerts.esQuery.ui.validation.error.requiredSizeText', {
|
||||
defaultMessage: 'Size is required.',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue