Skip to content

Commit

Permalink
Make sure index pattern has fields before parsing (elastic#58242)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Feb 21, 2020
1 parent 952589d commit 4f580c9
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ function getUniqueLayerCounts(layerCountsList, mapsCount) {
}

function getIndexPatternsWithGeoFieldCount(indexPatterns) {
const fieldLists = indexPatterns.map(indexPattern => JSON.parse(indexPattern.attributes.fields));
const fieldLists = indexPatterns.map(indexPattern =>
indexPattern.attributes && indexPattern.attributes.fields
? JSON.parse(indexPattern.attributes.fields)
: []
);
const fieldListsWithGeoFields = fieldLists.filter(fields => {
return fields.some(
field =>
Expand All @@ -50,7 +54,9 @@ function getIndexPatternsWithGeoFieldCount(indexPatterns) {

export function buildMapsTelemetry({ mapSavedObjects, indexPatternSavedObjects, settings }) {
const layerLists = mapSavedObjects.map(savedMapObject =>
JSON.parse(savedMapObject.attributes.layerListJSON)
savedMapObject.attributes && savedMapObject.attributes.layerListJSON
? JSON.parse(savedMapObject.attributes.layerListJSON)
: []
);
const mapsCount = layerLists.length;

Expand Down

0 comments on commit 4f580c9

Please sign in to comment.