From 560c763bedcbc92f06d77823b9c5c3114947fa35 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 5 May 2020 15:48:53 +0200 Subject: [PATCH] [Uptime] Console errors in case index missing (#65115) --- .../uptime/server/lib/requests/get_snapshot_counts.ts | 8 +++++++- .../server/lib/requests/search/find_potential_matches.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/uptime/server/lib/requests/get_snapshot_counts.ts b/x-pack/plugins/uptime/server/lib/requests/get_snapshot_counts.ts index b57bc87d454183..5f8a37cf070289 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_snapshot_counts.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_snapshot_counts.ts @@ -55,7 +55,13 @@ const statusCount = async (context: QueryContext): Promise => { body: statusCountBody(await context.dateAndCustomFilters()), }); - return res.aggregations.counts.value; + return ( + res.aggregations?.counts?.value ?? { + total: 0, + up: 0, + down: 0, + } + ); }; const statusCountBody = (filters: any): any => { diff --git a/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts b/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts index e60c52660915a1..a3e7324086073f 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts @@ -47,7 +47,7 @@ export const findPotentialMatches = async ( return { monitorIds, checkGroups, - searchAfter: queryResult.aggregations.monitors.after_key, + searchAfter: queryResult.aggregations?.monitors?.after_key, }; };