diff --git a/lib/parser.js b/lib/parser.js index 0ec140e..22d3527 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -143,15 +143,22 @@ function createValuesObject(valuesFilePath) { if (valuePathSplit.length > 1) { // The value is inside an array const arrayPrefix = utils.getArrayPrefix(valuePath); - let isPlainArray = true; // Assume it is plain until we prove the opposite - _.get(valuesJSON, arrayPrefix).forEach((e) => { - if (typeof e !== 'string') { - isPlainArray = false; + // Retrieve the value at arrayPrefix only if it's defined + const array = _.get(valuesJSON, arrayPrefix); + // Ensure array is actually defined and is an array + if (Array.isArray(array)) { + let isPlainArray = true; // Assume it is plain until we prove the opposite + array.forEach((e) => { + if (typeof e !== 'string') { + isPlainArray = false; + } + }); + if (isPlainArray) { + value = array; + valuePath = arrayPrefix; } - }); - if (isPlainArray) { - value = _.get(valuesJSON, arrayPrefix); - valuePath = arrayPrefix; + } else { + console.error(`Expected array at ${arrayPrefix}, found ${typeof array}`); } }