From b9de45b4704c48723dde022697761ee898dbe9a1 Mon Sep 17 00:00:00 2001 From: Juned Memon Date: Thu, 29 Aug 2024 13:19:07 +0530 Subject: [PATCH] Fixes the list inside a File.ext YAML key pattern is not correctly parsed Signed-off-by: Juned Memon --- lib/parser.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) 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}`); } }