From 9c1cbd6deab6bba38c71e4e5452f156fc9e63bae Mon Sep 17 00:00:00 2001 From: Yuliia Naumenko Date: Thu, 7 Jan 2021 14:38:20 -0800 Subject: [PATCH] fixed crash on zpd/api/event_log/alert/84c00970-5130-11eb-9fa7/_find for non existing id --- x-pack/plugins/actions/server/plugin.ts | 11 ++++++----- x-pack/plugins/alerts/server/plugin.ts | 9 ++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/actions/server/plugin.ts b/x-pack/plugins/actions/server/plugin.ts index 9b2109b3ef4fa..83c2628f9a225 100644 --- a/x-pack/plugins/actions/server/plugin.ts +++ b/x-pack/plugins/actions/server/plugin.ts @@ -334,11 +334,12 @@ export class ActionsPlugin implements Plugin, Plugi this.eventLogService!.registerSavedObjectProvider('action', (request) => { const client = secureGetActionsClientWithRequest(request); - return async (objects?: SavedObjectsBulkGetObject[]) => { - if (objects) { - Promise.all(objects.map(async (objectItem) => (await client).get({ id: objectItem.id }))); - } - }; + return (objects?: SavedObjectsBulkGetObject[]) => + objects + ? Promise.all( + objects.map(async (objectItem) => await (await client).get({ id: objectItem.id })) + ) + : new Promise(() => []); }); const getScopedSavedObjectsClientWithoutAccessToActions = (request: KibanaRequest) => diff --git a/x-pack/plugins/alerts/server/plugin.ts b/x-pack/plugins/alerts/server/plugin.ts index 5ba953c8d5260..ddb8eb58a8430 100644 --- a/x-pack/plugins/alerts/server/plugin.ts +++ b/x-pack/plugins/alerts/server/plugin.ts @@ -371,11 +371,10 @@ export class AlertingPlugin { this.eventLogService!.registerSavedObjectProvider('alert', (request) => { const client = getAlertsClientWithRequest(request); - return async (objects?: SavedObjectsBulkGetObject[]) => { - if (objects) { - Promise.all(objects.map(async (objectItem) => (await client).get({ id: objectItem.id }))); - } - }; + return (objects?: SavedObjectsBulkGetObject[]) => + objects + ? Promise.all(objects.map(async (objectItem) => await client.get({ id: objectItem.id }))) + : new Promise(() => []); }); scheduleAlertingTelemetry(this.telemetryLogger, plugins.taskManager);