[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>
This commit is contained in:
Robert Jaszczurek 2024-09-23 16:27:01 +02:00 committed by GitHub
parent 9f67292bca
commit 65b7bf9586
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,13 +32,15 @@ export const ConfigValidator: FC<ConfigValidatorProps> = 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<ConfigValidatorProps> = React.memo(
const notifyWhenWarning =
alertNotifyWhen === 'onActiveAlert' &&
lookbackIntervalInSeconds &&
alertIntervalInSeconds &&
alertIntervalInSeconds < lookbackIntervalInSeconds;
const bucketSpanDuration = parseInterval(jobConfigs[0].analysis_config.bucket_span!);