From 96f6c5be83174a779fd3e657cb5d7d1ff9759599 Mon Sep 17 00:00:00 2001 From: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:27:01 +0200 Subject: [PATCH] [ML][Rules] Fixes deletion in Check interval input for anomaly detection rule (#193420) ## Summary It was trying to parse `null` values. After: ![image](https://github.com/user-attachments/assets/82d24663-a895-4ad4-bc01-fb76b883bc66) Fixes [#190732](https://github.com/elastic/kibana/issues/190732) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 65b7bf9586480b522393905ff21324f473ee90ed) --- .../alerting/anomaly_detection_rule/config_validator.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/config_validator.tsx b/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/config_validator.tsx index 88b1502ac3b99..04e96546196bb 100644 --- a/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/config_validator.tsx +++ b/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/config_validator.tsx @@ -32,13 +32,15 @@ export const ConfigValidator: FC = React.memo( ({ jobConfigs = [], alertInterval, alertParams, alertNotifyWhen, maxNumberOfBuckets }) => { if (jobConfigs.length === 0) return null; - const alertIntervalInSeconds = parseInterval(alertInterval)!.asSeconds(); + const alertIntervalInSeconds = parseInterval(alertInterval)?.asSeconds(); const lookbackIntervalInSeconds = !!alertParams.lookbackInterval && parseInterval(alertParams.lookbackInterval)?.asSeconds(); const isAlertIntervalTooHigh = - lookbackIntervalInSeconds && lookbackIntervalInSeconds < alertIntervalInSeconds; + lookbackIntervalInSeconds && + alertIntervalInSeconds && + lookbackIntervalInSeconds < alertIntervalInSeconds; const jobWithoutStartedDatafeed = jobConfigs .filter((job) => job.datafeed_config.state !== DATAFEED_STATE.STARTED) @@ -49,6 +51,7 @@ export const ConfigValidator: FC = React.memo( const notifyWhenWarning = alertNotifyWhen === 'onActiveAlert' && lookbackIntervalInSeconds && + alertIntervalInSeconds && alertIntervalInSeconds < lookbackIntervalInSeconds; const bucketSpanDuration = parseInterval(jobConfigs[0].analysis_config.bucket_span!);