From 54876058ce9ef8ff813200eb5eae7b8558abb380 Mon Sep 17 00:00:00 2001 From: Tyler Ohlsen Date: Wed, 4 Jan 2023 15:29:50 -0800 Subject: [PATCH] Fix undefined entity list when heatmap is empty (#383) Signed-off-by: Tyler Ohlsen --- public/pages/utils/anomalyResultUtils.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/public/pages/utils/anomalyResultUtils.ts b/public/pages/utils/anomalyResultUtils.ts index 160afbb0..acb0b955 100644 --- a/public/pages/utils/anomalyResultUtils.ts +++ b/public/pages/utils/anomalyResultUtils.ts @@ -1767,10 +1767,17 @@ export const convertToCategoryFieldAndEntityString = ( if (index > 0) { entityString += delimiter; } + + // It is possible that entity.name is undefined when we artificially add + // whitespace strings as the entity values when the heatmap is empty (see + // getSampleAnomaliesHeatmapData()) + // If true, set the entire string as 'None' entityString += - entity.name + - `${HEATMAP_CALL_ENTITY_KEY_VALUE_DELIMITER}` + - entity.value; + entity.name !== undefined + ? entity.name + + `${HEATMAP_CALL_ENTITY_KEY_VALUE_DELIMITER}` + + entity.value + : 'None'; }); } return entityString;