Skip to content

fix: Exporting Bruno collection as Postman collection omits collection variables - #6117

Merged
sid-bruno merged 6 commits into
usebruno:mainfrom
chirag-bruno:bugfix/postman-export-omit-collection-vars
Dec 2, 2025
Merged

sid-bruno merged 6 commits into
usebruno:mainfrom
chirag-bruno:bugfix/postman-export-omit-collection-vars

Conversation

@chirag-bruno

@chirag-bruno chirag-bruno commented Nov 17, 2025 •

Copy link
Copy Markdown
Collaborator

Description

This PR addresses the issue described in JIRA. The earlier implementation relied on pattern matching to export variables, which caused it to miss variables defined in the collection’s pre-request and post-request variable lists. This update resolves the problem by retrieving variables directly from the collection object and removing the pattern-matching approach.

Closes: #2162

Contribution Checklist:

  • 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.

Summary by CodeRabbit

  • Bug Fixes
    • Improved variable handling when converting Bruno collections to Postman format: variables are now returned as structured objects (key, value, type) instead of plain strings.
    • Request- and response-level variables are merged and deduplicated, preserving initial values and types for more accurate, consistent conversions.

✏️ Tip: You can customize this high-level summary in your review settings.

…es from collection root and removed the pattern matching implementation
- Replace recursive traversal with iterative stack-based approach
- Use Set/Map for O(1) deduplication instead of array operations
- Use matchAll() for more efficient regex matching
- Improves performance for large collections and avoids stack overflow
@coderabbitai

coderabbitai Bot commented Dec 2, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

generateCollectionVars in bruno-to-postman.js was rewritten to collect variables as objects { key, value, type } instead of strings, merge request- and response-level vars, deduplicate by key, and preserve initial values when available for Postman export.

Changes

Cohort / File(s) Change Summary
Variable Structure & Merge Logic
packages/bruno-converters/src/postman/bruno-to-postman.js
Replaced listOfVars (string array) with collectionVars (array of { key, value, type }). When parsing templates, push objects instead of strings. Use collectionVars with findOccurrences. Combine request-level (collection.root.request.vars) and response-level vars into final set, deduplicate by key, and preserve initial values where present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Verify deduplication correctly resolves collisions between request, response, and found vars (priority/source rules).
  • Confirm type is consistently set for all variable sources.
  • Ensure values from collection.root.request.vars are taken when present and not overwritten erroneously.
  • Test template detection and findOccurrences integration with the new object shape.

Poem

✨ In templates once strings would roam,

Now keyed and typed they find a home.
Requests and responses join the choir,
No value lost, each spark of fire.
Bruno hands Postman a whole new tome.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main fix: addressing omitted collection variables when exporting Bruno to Postman format.
Linked Issues check ✅ Passed The changes directly address #2162 by retrieving variables from the collection object instead of pattern matching, ensuring variable values and pre/post-request variables are preserved during export.
Out of Scope Changes check ✅ Passed All changes are scoped to the Bruno-to-Postman conversion logic and directly target the variable export issue described in #2162.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 150debc and dace0e3.

📒 Files selected for processing (1)
  • packages/bruno-converters/src/postman/bruno-to-postman.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single parameters
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses. Keep 'em tight
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Avoid single line abstractions where all that's being done is increasing the call stack with one additional function
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-converters/src/postman/bruno-to-postman.js
🧬 Code graph analysis (1)
packages/bruno-converters/src/postman/bruno-to-postman.js (1)
packages/bruno-app/src/utils/collections/index.js (1)
  • collectionVars (1583-1583)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: CLI Tests
  • GitHub Check: Unit Tests
🔇 Additional comments (2)
packages/bruno-converters/src/postman/bruno-to-postman.js (2)

146-157: LGTM!

Correctly retrieves request and response vars from collection.root.request.vars, mapping Bruno's name/value properties to Postman's key/value format. This addresses the core issue where collection variables were omitted.


159-168: LGTM!

Deduplication correctly prioritizes reqVars and resVars (with actual values) over pattern-matched collectionVars (empty values). The "first wins" approach ensures exported variables retain their configured values.


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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e88671 and 150debc.

📒 Files selected for processing (1)
  • packages/bruno-converters/src/postman/bruno-to-postman.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single parameters
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses. Keep 'em tight
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Avoid single line abstractions where all that's being done is increasing the call stack with one additional function
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-converters/src/postman/bruno-to-postman.js
🧬 Code graph analysis (1)
packages/bruno-converters/src/postman/bruno-to-postman.js (1)
packages/bruno-app/src/utils/collections/index.js (1)
  • collectionVars (1583-1583)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
  • GitHub Check: CLI Tests
🔇 Additional comments (2)
packages/bruno-converters/src/postman/bruno-to-postman.js (2)

119-121: LGTM! Variable naming is clearer.

The rename from listOfVars to collectionVars better reflects the purpose of this array.


147-168: Nice! Variable merging logic preserves values correctly.

The merge order [...reqVars, ...resVars, ...collectionVars] with first-key-wins deduplication ensures that explicitly defined variables from collection.root.request.vars retain their values and take precedence over template-discovered variables. This directly addresses the issue where variable values were being lost during export.

@sid-bruno
sid-bruno force-pushed the bugfix/postman-export-omit-collection-vars branch from 150debc to dace0e3 Compare December 2, 2025 11:02
@sid-bruno
sid-bruno merged commit ee4c923 into usebruno:main Dec 2, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Dec 2, 2025
5 tasks
naman-bruno pushed a commit to naman-bruno/bruno that referenced this pull request Dec 3, 2025
…ort-omit-collection-vars

fix: Exporting Bruno collection as Postman collection omits collection variables
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.

Export as a Postman Collection removes Variable Value

2 participants