Skip to content

fix: 3093 - Fix pm.setNextRequest(null) not translating to bru.runner.stopExecution() - #8049

Merged
bijin-bruno merged 3 commits into
usebruno:mainfrom
sharan-bruno:fix/pm.setNextRequest(null)-not-translating
May 20, 2026
Merged

bijin-bruno merged 3 commits into
usebruno:mainfrom
sharan-bruno:fix/pm.setNextRequest(null)-not-translating

Conversation

@sharan-bruno

@sharan-bruno sharan-bruno commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Jira link: https://usebruno.atlassian.net/browse/BRU-3093

Description

Fix pm.setNextRequest(null) / pm.setNextRequest('null') translating to a no-op
bru.setNextRequest(null) instead of bru.runner.stopExecution().

In Postman, passing null stops the collection runner. Bruno's setNextRequest
only nulls the next-request pointer; only bru.runner.stopExecution() actually
stops the runner — so imported scripts were silently broken.

  • AST translator: replaced the 1:1 pm.setNextRequest mapping with a complex
    transform that emits bru.runner.stopExecution() for null / 'null' literals,
    otherwise bru.setNextRequest(arg).
  • Regex fallback: added null / 'null' specific patterns before the general
    pm.setNextRequest( rule.
  • Added unit tests for both null variants.

Mirrors the existing pm.execution.setNextRequest(null) handling.
Fixes BRU-1367 / BRU-3093.

Before:
image

After:
image

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

Packages changed:

  • packages/bruno-converters

What changed

  • Fixes translation of pm.setNextRequest(null) and pm.setNextRequest("null") so they map to bru.runner.stopExecution() instead of producing a no-op bru.setNextRequest(null).
  • Replaced the previous simple 1:1 pm.setNextRequest translation with an AST transformation that:
    • Emits bru.runner.stopExecution() for null or string-'null' literal arguments.
    • Emits bru.runner.setNextRequest(...) for other arguments (preserving intended behavior).
  • Added a higher-priority regex fallback for null / "null" patterns before the general pm.setNextRequest( rule to cover non-AST fallback paths.
  • Aligned behavior with existing pm.execution.setNextRequest(null) handling.
  • Adjusted tests and expectations to reflect bru.runner.* usage where appropriate.

Tests

  • Added unit tests asserting pm.setNextRequest(null) and pm.setNextRequest("null") translate to bru.runner.stopExecution().
  • Updated existing translation tests to expect bru.runner.setNextRequest(...) rather than bru.setNextRequest(...) for non-null cases.
  • Updated corresponding Bruno→Postman translation test to use bru.runner.setNextRequest(...) input where applicable.

Issues fixed

  • Addresses BRU-1367 / BRU-3093.

Notes on scope/interdependencies

  • Changes are confined to the bruno-converters package (translation logic + tests). No exported public API changes outside tests.
  • Translation behavior change affects any tooling that relies on bruno-converters for Postman→Bruno transpilation; callers should expect bru.runner.stopExecution() for null cases and bru.runner.setNextRequest(...) otherwise.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Translator now treats pm.setNextRequest(null) and pm.setNextRequest('null') as stop signals and emits bru.runner.stopExecution(); other pm.setNextRequest(...) calls are emitted as bru.runner.setNextRequest(...). Corresponding translation patterns, AST transformation, and tests were updated.

Changes

pm.setNextRequest null translation

Layer / File(s) Summary
Stop-execution translation patterns
packages/bruno-converters/src/postman/postman-translations.js
Regex/replacement entries added to match pm.setNextRequest(null) and pm.setNextRequest('null') and emit bru.runner.stopExecution() with higher priority.
Complex setNextRequest transformation
packages/bruno-converters/src/utils/postman-to-bruno-translator.js
Removed simple 1:1 pm.setNextRequest mapping; added AST handler that checks the first argument and emits bru.runner.stopExecution() for null/'null', otherwise bru.runner.setNextRequest(...).
Updated tests and expectations
packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/exec-flow.test.js, packages/bruno-converters/tests/bruno/bruno-to-postman-translations/execution.test.js, packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/postman-references.test.js
Added tests asserting pm.setNextRequest(null) and pm.setNextRequest("null") translate to bru.runner.stopExecution();. Updated expectations to use bru.runner.setNextRequest(...) where applicable.

Sequence Diagram(s)

sequenceDiagram
  participant PostmanScript
  participant Translator
  participant BruRunner
  PostmanScript->>Translator: pm.setNextRequest(null)
  Translator->>BruRunner: bru.runner.stopExecution()
  alt non-null argument
    PostmanScript->>Translator: pm.setNextRequest("Get User Details")
    Translator->>BruRunner: bru.runner.setNextRequest("Get User Details")
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • usebruno/bruno#7052: Implements similar null-to-stopExecution mapping for pm.execution.setNextRequest within the same translator infrastructure.

Suggested labels

size/S

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

🛑 A null next request, a quiet bell,
The runner halts — no more to tell.
Translations tuned, the flow is neat,
StopExecution makes it complete. 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main fix: translating pm.setNextRequest(null) to bru.runner.stopExecution() instead of a no-op.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/bruno-converters/src/postman/postman-translations.js`:
- Around line 21-22: The current fallback patterns for pm.setNextRequest(null)
don't allow spaces inside the parentheses, so variants like pm.setNextRequest(
null ) or pm.setNextRequest( "null" ) won't match and fall back to
bru.setNextRequest; update the two translation keys for
'pm\\.setNextRequest\\(null\\)' and 'pm\\.setNextRequest\\([\'\"]null[\'\"]\\)'
to accept optional whitespace inside the parentheses by adding \s* around the
null and around the quoted null (i.e., use patterns like
pm\.setNextRequest\(\s*null\s*\) and pm\.setNextRequest\(\s*[\'"]null[\'"]\s*\)
), keeping their replacement value as bru.runner.stopExecution(); this will
ensure pm.setNextRequest variants map to bru.runner.stopExecution instead of
bru.setNextRequest.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c22fba9c-f735-485a-bbbe-65742d9d382a

📥 Commits

Reviewing files that changed from the base of the PR and between e0de7d5 and b457081.

📒 Files selected for processing (3)
  • packages/bruno-converters/src/postman/postman-translations.js
  • packages/bruno-converters/src/utils/postman-to-bruno-translator.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/exec-flow.test.js

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/exec-flow.test.js (1)

23-27: ⚡ Quick win

Remove or repurpose this duplicate pm.setNextRequest test.

This case repeats the same non-null translation already asserted above, and the test title still mentions bru.setNextRequest(...) while expecting bru.runner.setNextRequest(...). Consider deleting it or changing it to a genuinely different input case.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/exec-flow.test.js`
around lines 23 - 27, The test duplicating pm.setNextRequest should be removed
or repurposed: locate the test using pm.setNextRequest in exec-flow.test.js (the
one that calls translateCode and expects 'bru.runner.setNextRequest(...)') and
either delete it or change it to a distinct scenario (e.g., null/undefined
argument or a different request name) and update the test title to match the new
behavior; ensure the assertion aligns with the translator function translateCode
and with the correct target symbol (bru.setNextRequest vs
bru.runner.setNextRequest) used elsewhere in the suite.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/exec-flow.test.js`:
- Around line 23-27: The test duplicating pm.setNextRequest should be removed or
repurposed: locate the test using pm.setNextRequest in exec-flow.test.js (the
one that calls translateCode and expects 'bru.runner.setNextRequest(...)') and
either delete it or change it to a distinct scenario (e.g., null/undefined
argument or a different request name) and update the test title to match the new
behavior; ensure the assertion aligns with the translator function translateCode
and with the correct target symbol (bru.setNextRequest vs
bru.runner.setNextRequest) used elsewhere in the suite.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6ffcb853-7efd-4aa0-b5e5-b2813dcddc5e

📥 Commits

Reviewing files that changed from the base of the PR and between b457081 and e99d467.

📒 Files selected for processing (4)
  • packages/bruno-converters/src/utils/postman-to-bruno-translator.js
  • packages/bruno-converters/tests/bruno/bruno-to-postman-translations/execution.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/exec-flow.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/postman-references.test.js

@bijin-bruno
bijin-bruno merged commit 4b21469 into usebruno:main May 20, 2026
17 of 19 checks passed
lyh543 pushed a commit to lyh543/bruno that referenced this pull request May 22, 2026
….stopExecution() (usebruno#8049)

* fix: 3093 - Fix pm.setNextRequest(null) not translating to bru.runner.stopExecution()

* addressed review comments

* addressed review comments
jattsson pushed a commit to jattsson/bruno that referenced this pull request May 26, 2026
….stopExecution() (usebruno#8049)

* fix: 3093 - Fix pm.setNextRequest(null) not translating to bru.runner.stopExecution()

* addressed review comments

* addressed review comments
sharan-bruno added a commit to sharan-bruno/bruno that referenced this pull request Jun 4, 2026
….stopExecution() (usebruno#8049)

* fix: 3093 - Fix pm.setNextRequest(null) not translating to bru.runner.stopExecution()

* addressed review comments

* addressed review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants