Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the field exists in the index pattern before grabbing it #20639

Merged
merged 1 commit into from
Jul 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ui/public/filter_bar/lib/map_phrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down