Skip to content

fix: nested folder issue#3353

Open
kobenguyent wants to merge 4 commits intopostmanlabs:developfrom
kobenguyent:copilot/fix-nested-folder-issue
Open

fix: nested folder issue#3353
kobenguyent wants to merge 4 commits intopostmanlabs:developfrom
kobenguyent:copilot/fix-nested-folder-issue

Conversation

@kobenguyent
Copy link
Copy Markdown

@kobenguyent kobenguyent commented Mar 26, 2026

Newman had a bug where specifying both a parent folder and one of its non-direct nested descendants via --folder caused the descendant's requests to execute twice. Additionally, there was no test coverage for the --folder option when targeting nested folders.

Root Cause

When postman-runtime's findItemsOrGroups traverses a non-matching intermediate folder (e.g. Parent → Intermediate → DeepNested), it resets the _continueAccumulation flag to true for that branch. This causes DeepNested to be accumulated even when Parent (which already covers it) is also specified — making its requests execute twice.

Changes

  • lib/run/index.js — Added two private helpers and applied deduplication before entrypoint construction:

    • findItemOrGroupById() — recursively locates a folder or request in the collection by id or name
    • deduplicateFolders() — for each folder in a multi-folder list, walks up the parent chain to check whether any ancestor is also in the list; if so, removes the descendant (since running the ancestor already covers all its children)
    • Applied deduplicateFolders() in the entrypoint construction block before the multipleIdOrName lookup strategy is invoked
  • test/library/folder-variants.test.js — Added fixture collections and a nested folders describe block with 8 tests covering:

    • Single nested folder via string: folder: '1.2 Hello2'
    • Single nested folder via single-item array (CLI code path): folder: ['1.2 Hello2']
    • Parent folder runs all descendant requests
    • Multiple nested folders via array (multipleIdOrName strategy)
    • Parent + non-direct nested descendant runs requests exactly once (regression for the bug above)
    • Parent + multiple nested descendants at different levels runs requests exactly once
    • Invalid nested folder name produces correct error
    • 3-level deep folder resolves correctly
// Bug scenario — before fix, R1 ran twice:
// Parent → Intermediate → DeepNested → R1
newman.run({ collection, folder: ['Parent', 'DeepNested'] }, (err, summary) => {
    // executions: ['R1'] — runs exactly once after fix
});

Copilot AI and others added 4 commits March 26, 2026 11:09
…e both specified via --folder

Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kobenguyent/newman/sessions/e6ab8a99-b00d-4032-85eb-7a73d35b7959
…ted scenario)

Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kobenguyent/newman/sessions/6eddf2da-3362-4fc9-b10e-26806dbf74d0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants