skip to content

In Newman, what runs when a `--folder` value matches a request rather than a folder?

level: middleimportance: should knowfreq 40%

answer

  1. The option's name is narrower than the lookup
  2. Requests and folders share one item tree
  3. One matched request means one call
  4. No climb to the parent folder
  5. A shared name silently shrinks the run

basics

~20 s

Just that one request. Newman's --folder lookup matches requests as well as folders, so a value naming a single request makes that request the run's entry point and nothing else in the collection is sent.

solid answer

~40 s

The option is named `--folder`, but the lookup it drives is not folder-only. Requests and folders sit side by side in the collection's `item` arrays and are resolved by the same id-or-name comparison, so a value equal to a request's name or id resolves to that request. It becomes the run's `entrypoint.execute`, and the run consists of exactly that one call — there is no climb to the enclosing folder and no expansion to its siblings. That makes it the quickest way to re-run one request from a terminal without editing the collection. It is also a trap: if a request and a folder share a name, whichever the traversal reaches first wins, so an operator expecting a folder can get a single request instead.

code

bash · 1 line
bash
newman run collection.json --folder "Create order"

go deeper

for a junior

Know that --folder is not restricted to folders: give it a request's name and just that one request runs, which is handy for re-running a single call from a terminal.

for a middle

Explain the reason rather than the fact: requests and folders are entries in the same item tree resolved by one id-or-name lookup, so the entry point can be either kind.

for a senior

Be ready with the failure mode — a request sharing a folder's name shrinks a run to one call while still passing — and with the detection: check which requests executed, not the verdict.

for a principal

Frame it as naming policy across a shared collection: because kind is invisible to the lookup, name collisions between a request and a folder are a defect worth catching in review.

## The answer, and why it surprises people A value passed to `--folder` that equals a **request's** name or id resolves to that request, and the run then consists of **exactly that one call**. The option's name promises folders; the lookup behind it does not restrict itself to them. The reason is structural. A collection file's `item` array is **heterogeneous**: an entry is a folder when it carries its own nested `item` list, and a request otherwise. Both kinds are ordinary entries in the same tree, and the default **`idOrName`** lookup that resolves `entrypoint.execute` compares the value against an entry's **id or name** without asking which kind of entry it found. Whatever it matches first becomes the run's entry point. ## What executes, precisely - The matched request becomes the entry point; **nothing else in the collection is sent**. - There is **no climb to the parent**. Matching a request does not select the folder containing it and does not start the folder "from that request onward". - There is **no expansion to siblings**. A request's neighbours in the same folder are simply not part of the selected subtree. - **First match still wins.** Further entries sharing the name are never reached, whether they are requests or folders. | Value matches | Entry point | Requests sent | |---|---|---| | a folder | that folder | its subtree, flattened, in file order | | a request | that request | exactly one | | a request that shares a folder's name | whichever the walk reaches first | one, or a whole subtree | | nothing | none | none; the run fails to start | ## Why this is useful Re-running a single call from a terminal is a common need — a request failed in a long run and you want it alone, or you are iterating on one script and do not want its neighbours' side effects. Because the lookup accepts a request, that need costs nothing: no temporary folder, no edited copy of the collection, no second file. The selection is expressed entirely on the command line and the collection under version control is untouched. ## Why it is also a trap The same property produces a failure mode that is hard to see: 1. Somebody names a request the same as a folder — `Login` as both a folder of auth calls and a single request inside it is the classic shape. 2. A command line selects `Login` expecting the folder. 3. The traversal reaches one of them first and the run executes **one request** instead of the folder's subtree. 4. The run passes, because the one request that ran was fine. The checks that did not run cannot fail. The defence is the same as for duplicate folder names: keep names unique across the whole file, and verify **which** requests executed rather than only that the run was clean. ## What stays outside this decision Selection answers one question only — *which entries execute*. It does not decide what an enclosing folder or the collection itself contributes to a request that runs inside it; how declarations attach to a request through its ancestors is a separate subject with its own rules. Nor does selection have anything to do with changing the sequence once a run is under way: naming the next request to visit, or dropping the current one, is a different mechanism belonging to the sandbox's execution API. ## How to answer it in an interview Say the fact first — *yes, `--folder` matches a request, and then exactly that request runs* — then give the reason, which is what shows understanding: requests and folders are entries in the same `item` tree and share one id-or-name lookup, so the option cannot tell them apart and does not try. Close with the consequence: it is a genuinely convenient way to re-run one call, and a real hazard whenever a request and a folder in the same collection share a name.

  • If a request and a folder in one collection share a name, which does `--folder` select?
    Whichever the traversal reaches first — kind is not part of the comparison. Own children come before deeper ones, then position in the `item` array decides. The outcome differs enormously (one call versus a whole subtree) yet raises no warning, which is why names should be unique across the file rather than merely within a folder.
  • Does selecting a single request start its enclosing folder from that point onward?
    No. Resolution never climbs to a parent. The matched request is the entry point on its own, so its siblings — before it or after it — are not part of the run. If you want the folder's sequence, name the folder; there is no partial-folder form of this selection.

saying these in an interview costs you the question

  • Insists --folder rejects anything that is not a folder
  • Says the enclosing folder runs from the matched request onward
  • Expects sibling requests in the same folder to run too
  • Believes a request-only variant of the option exists
  • Ignores that a shared name makes the outcome unpredictable