When a collection is contained in an external JSON file, the behavior wrt how it is processed differs between the CLI interface and the programmatic interface in a surprising way.
When passed as a filepath, the collection can be loaded if it's in a JSON object OR if it's in a JSON object under the key collection, but when passed as JSON directly, this unwrapping doesn't happen. The unwrapping happens here:
This leads to surprising behavior, as my expectation was that running a json file that works on the CLI would also work when passed as part of a script. There is no feedback that the formatting of the json could be the issue and be causing the difference.
Newman Version (can be found via newman -v): 6.0.0
OS details (type, version, and architecture): Mac Ventura M2
Are you using Newman as a library, or via the CLI? Both, see issue
Did you encounter this recently, or has this bug always been there: Idk
Expected behaviour: Consistency between CLI and programmatic use
Command / script used to run Newman:
Sample collection, and auxiliary files (minus the sensitive details):
reproduction
I don't have the context to know what the expected behavior should be, other than I think passing a path and passing a JSON object should work consistently. I can see there is a lot of backwards compatibility stuff going on too. I'm filing this issue so that there is some visibility into the surprising behavior.
When a collection is contained in an external JSON file, the behavior wrt how it is processed differs between the CLI interface and the programmatic interface in a surprising way.
When passed as a filepath, the collection can be loaded if it's in a JSON object OR if it's in a JSON object under the key
collection
, but when passed as JSON directly, this unwrapping doesn't happen. The unwrapping happens here:https://github.com/postmanlabs/newman/blob/a612fbe29348eaae5f6aac0b882382d23d688ac3/lib/run/options.js#L60
This leads to surprising behavior, as my expectation was that running a json file that works on the CLI would also work when passed as part of a script. There is no feedback that the formatting of the json could be the issue and be causing the difference.
Newman Version (can be found via
newman -v
): 6.0.0OS details (type, version, and architecture): Mac Ventura M2
Are you using Newman as a library, or via the CLI? Both, see issue
Did you encounter this recently, or has this bug always been there: Idk
Expected behaviour: Consistency between CLI and programmatic use
Command / script used to run Newman:
Sample collection, and auxiliary files (minus the sensitive details): reproduction
Reproduction can be found in this diff in this branch
I don't have the context to know what the expected behavior should be, other than I think passing a path and passing a JSON object should work consistently. I can see there is a lot of backwards compatibility stuff going on too. I'm filing this issue so that there is some visibility into the surprising behavior.
Thanks!