From 6ce0bc47025908eb06bd4724257f2ee3c82df11b Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 16 Aug 2018 13:38:15 -0700 Subject: [PATCH 1/2] Fix kibana_settings collector to return nothing when no settings data is found --- .../collectors/get_settings_collector.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js b/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js index 1382abb4ea293..4418388a004f3 100644 --- a/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js +++ b/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js @@ -61,7 +61,7 @@ export function getSettingsCollector(server, kbnServer) { return collectorSet.makeStatsCollector({ type: KIBANA_SETTINGS_TYPE, async fetch(callCluster) { - let kibanaSettingsData; + let kibanaSettingsData = null; const defaultAdminEmail = await checkForEmailValue(config, callCluster); // skip everything if defaultAdminEmail === undefined @@ -79,10 +79,16 @@ export function getSettingsCollector(server, kbnServer) { // remember the current email so that we can mark it as successful if the bulk does not error out shouldUseNull = !!defaultAdminEmail; - return { - kibana: getKibanaInfoForStats(server, kbnServer), - ...kibanaSettingsData - }; + // return nothing when there was no result + let settingsDoc; + if (kibanaSettingsData != null) { // test null or undefined + settingsDoc = { + kibana: getKibanaInfoForStats(server, kbnServer), + ...kibanaSettingsData + }; + } + + return settingsDoc; } }); } From b476642875347595ea3e6ea579fdaa70a955b0b0 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 16 Aug 2018 14:23:01 -0700 Subject: [PATCH 2/2] make code more clear --- .../kibana_monitoring/collectors/get_settings_collector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js b/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js index 4418388a004f3..401ee9f4766cb 100644 --- a/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js +++ b/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js @@ -81,7 +81,7 @@ export function getSettingsCollector(server, kbnServer) { // return nothing when there was no result let settingsDoc; - if (kibanaSettingsData != null) { // test null or undefined + if (kibanaSettingsData !== null) { settingsDoc = { kibana: getKibanaInfoForStats(server, kbnServer), ...kibanaSettingsData