From 07e5c7ba99f35f31a2592023f9cbc29568d82b9e Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:27:55 -0800 Subject: [PATCH] [Data Explorer] Fix missing field error from taking down the page (#5626) (#5748) * Handle missing fields error Signed-off-by: Ashwin P Chandran * adds changelog Signed-off-by: Ashwin P Chandran * ndo unnecessary changes to changelog Signed-off-by: Ashwin P Chandran * cleanup changelog Signed-off-by: Ashwin P Chandran * Fix PR number Signed-off-by: Ashwin P Chandran --------- Signed-off-by: Ashwin P Chandran (cherry picked from commit 28c1fbb84550d33a036e231661867988af5ebe54) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] --- .../components/chart/utils/create_histogram_configs.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/chart/utils/create_histogram_configs.ts b/src/plugins/discover/public/application/components/chart/utils/create_histogram_configs.ts index 8e659e73f9d7..bfc6e4e480c7 100644 --- a/src/plugins/discover/public/application/components/chart/utils/create_histogram_configs.ts +++ b/src/plugins/discover/public/application/components/chart/utils/create_histogram_configs.ts @@ -25,5 +25,13 @@ export function createHistogramConfigs( }, }, ]; - return data.search.aggs.createAggConfigs(indexPattern, visStateAggs); + + // If index pattern is created before the index, this function will fail since the required fields for the histogram agg will be missing. + try { + return data.search.aggs.createAggConfigs(indexPattern, visStateAggs); + } catch (error) { + // Just display the error to the user but continue to render the rest of the page + data.search.showError(error as Error); + return; + } }