From 70075bd592ebbb25271b43760581fa6c2432444b Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Wed, 17 Feb 2021 18:56:37 +0200 Subject: [PATCH] Fix bug --- x-pack/plugins/case/server/client/cases/utils.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/case/server/client/cases/utils.ts b/x-pack/plugins/case/server/client/cases/utils.ts index 6b3f365af449d..712780da2d756 100644 --- a/x-pack/plugins/case/server/client/cases/utils.ts +++ b/x-pack/plugins/case/server/client/cases/utils.ts @@ -172,18 +172,21 @@ export const createIncident = async ({ }, 0) ?? 0; let comments: ExternalServiceComment[] = []; + if (commentsToBeUpdated && Array.isArray(commentsToBeUpdated) && commentsToBeUpdated.length > 0) { const commentsMapping = mappings.find((m) => m.source === 'comments'); if (commentsMapping?.action_type !== 'nothing') { comments = transformComments(commentsToBeUpdated, ['informationAdded']); - if (totalAlerts > 0) { - comments.push({ - comment: `Elastic Security Alerts attached to the case: ${totalAlerts}`, - commentId: '', - }); - } } } + + if (totalAlerts > 0) { + comments.push({ + comment: `Elastic Security Alerts attached to the case: ${totalAlerts}`, + commentId: '', + }); + } + return { incident, comments }; };