From 16608ee2ceecfde1da117496c95537de879e00e9 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Fri, 12 Jun 2020 20:07:12 +0100 Subject: [PATCH] Fix type to account for undefined group_key --- .../infra/common/alerting/logs/types.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/infra/common/alerting/logs/types.ts b/x-pack/plugins/infra/common/alerting/logs/types.ts index 37a8e1effd988a..8ee517ceead6d5 100644 --- a/x-pack/plugins/infra/common/alerting/logs/types.ts +++ b/x-pack/plugins/infra/common/alerting/logs/types.ts @@ -138,15 +138,19 @@ export const GroupedSearchQueryResponseRT = rt.intersection([ commonSearchSuccessResponseFieldsRT, rt.type({ aggregations: rt.type({ - groups: rt.type({ - buckets: rt.array( - rt.type({ - key: rt.record(rt.string, rt.string), - doc_count: rt.number, - }) - ), - after_key: rt.record(rt.string, rt.string), - }), + groups: rt.intersection([ + rt.type({ + buckets: rt.array( + rt.type({ + key: rt.record(rt.string, rt.string), + doc_count: rt.number, + }) + ), + }), + rt.partial({ + after_key: rt.record(rt.string, rt.string), + }), + ]), }), hits: rt.type({ total: rt.type({