Skip to content

Commit aa72fee

Browse files
committed
Support reading multiple or single job id
1 parent 9b2fea9 commit aa72fee

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/kibana/security_detection_rule/models_machine_learning.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,13 @@ func (d *SecurityDetectionRuleData) updateFromMachineLearningRule(ctx context.Co
230230
// ML-specific fields
231231
d.AnomalyThreshold = types.Int64Value(int64(rule.AnomalyThreshold))
232232

233-
// Handle ML job ID(s)
234-
if multipleJobIds, err := rule.MachineLearningJobId.AsSecurityDetectionsAPIMachineLearningJobId1(); err == nil {
233+
// Handle ML job ID(s) - can be single string or array
234+
// Try to extract as single job ID first, then as array
235+
if singleJobId, err := rule.MachineLearningJobId.AsSecurityDetectionsAPIMachineLearningJobId0(); err == nil {
236+
// Single job ID
237+
d.MachineLearningJobId = utils.ListValueFrom(ctx, []string{string(singleJobId)}, types.StringType, path.Root("machine_learning_job_id"), &diags)
238+
} else if multipleJobIds, err := rule.MachineLearningJobId.AsSecurityDetectionsAPIMachineLearningJobId1(); err == nil {
239+
// Multiple job IDs
235240
jobIdStrings := make([]string, len(multipleJobIds))
236241
for i, jobId := range multipleJobIds {
237242
jobIdStrings[i] = string(jobId)

0 commit comments

Comments
 (0)