From 2eed12748fe078997b4ace7d52dbabb4c2e00555 Mon Sep 17 00:00:00 2001 From: Shiva953 Date: Tue, 9 Jan 2024 18:25:16 +0530 Subject: [PATCH] fix: Unwrap JSON collection in programmatic interface Fixes inconsistency in handling JSON collections loaded directly in the programmatic interface. Checks for "values" property to distinguish variables from collections, ensuring consistent behavior. - Modified extractModel function in newman/lib/run/options.js --- lib/run/options.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/run/options.js b/lib/run/options.js index 19c876ce2..130870fe6 100644 --- a/lib/run/options.js +++ b/lib/run/options.js @@ -52,12 +52,21 @@ var _ = require('lodash'), */ extractModel = function (source, type) { source = source[type] || source; // extract object that holds variable. these usually come from cloud API + + if (_.isObject(source) && !source.values) { + // Check if the source is an object and doesn't have a "values" property + // If it's an object, unwrap it if needed + source = source.collection || source; + } + if (!_.isObject(source)) { return undefined; } // ensure we un-box the JSON if it comes from cloud-api or similar sources - !source.values && _.isObject(source[type]) && (source = source[type]); + if (!source.values && _.isObject(source[type])) { + source = source[type]; + } // we ensure that environment passed as array is converted to plain object. runtime does this too, but we do it // here for consistency of options passed to reporters