From a28c6846cb4d1a4fc06290b0a62b463f6ab649b7 Mon Sep 17 00:00:00 2001 From: trevan Date: Fri, 13 Jul 2018 14:32:50 -0600 Subject: [PATCH] Ensure the field exists in the index pattern before grabbing it (#20639) --- src/ui/public/filter_bar/lib/map_phrase.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/public/filter_bar/lib/map_phrase.js b/src/ui/public/filter_bar/lib/map_phrase.js index 75e4a9224ffa8..25018d4746e2b 100644 --- a/src/ui/public/filter_bar/lib/map_phrase.js +++ b/src/ui/public/filter_bar/lib/map_phrase.js @@ -33,11 +33,11 @@ export function FilterBarLibMapPhraseProvider(Promise, indexPatterns) { const params = isScriptedPhraseFilter ? filter.script.script.params : filter.query.match[key]; const query = isScriptedPhraseFilter ? params.value : params.query; - // Sometimes a filter will end up with an invalid index param. This could happen for a lot of reasons, + // Sometimes a filter will end up with an invalid index or field param. This could happen for a lot of reasons, // for example a user might manually edit the url or the index pattern's ID might change due to // external factors e.g. a reindex. We only need the index in order to grab the field formatter, so we fallback - // on displaying the raw value if the index is invalid. - const value = indexPattern ? indexPattern.fields.byName[key].format.convert(query) : query; + // on displaying the raw value if the index or field is invalid. + const value = (indexPattern && indexPattern.fields.byName[key]) ? indexPattern.fields.byName[key].format.convert(query) : query; return { type, key, value, params }; }