Skip to content

fix: multipart form-data file param export/import for Postman - #7111

Merged
sid-bruno merged 1 commit into
usebruno:mainfrom
chirag-bruno:fix/multipart-formdata-file-default-content-type
Feb 12, 2026
Merged

sid-bruno merged 1 commit into
usebruno:mainfrom
chirag-bruno:fix/multipart-formdata-file-default-content-type

Conversation

@chirag-bruno

@chirag-bruno chirag-bruno commented Feb 11, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixed import and export issue in Bruno <-> Postman where an auto type marked file in multipart request was being set as default and no source would be added.

JIRA

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

Release Notes

  • Bug Fixes

    • Improved multipart form data conversion between Postman and Bruno formats.
    • Enhanced handling of file uploads and text fields during format conversions.
    • Fixed content type preservation for form data entries.
  • Tests

    • Expanded test coverage for multipart form data conversion scenarios.

@coderabbitai

coderabbitai Bot commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Unifies multipart form data handling between Postman and Bruno converters through file-aware logic. Distinguishes file items (type: 'file', src property) from text items (type: 'text', value property), with conditional contentType inclusion. Adds comprehensive test coverage for both conversion directions.

Changes

Cohort / File(s) Summary
Production Logic
packages/bruno-converters/src/postman/bruno-to-postman.js, packages/bruno-converters/src/postman/postman-to-bruno.js
Enhanced multipart form data handling with unified file detection. Bruno→Postman: introduces isFile flag to conditionally set type and src/value. Postman→Bruno: refactors value construction with isFile determined by param.type or src presence; applies same logic to primary and example body transformations.
Test Coverage
packages/bruno-converters/tests/postman/bruno-to-postman.spec.js, packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js
Comprehensive test suites for multipart form conversions. Covers file/text type mapping, contentType preservation, mixed field scenarios, enabled/disabled flags, and edge cases (string values, empty values, array handling).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

size/M

Suggested reviewers

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

Poem

📋 Files dance between formats, file and text unite,

src and value in harmony, logic shining bright,

Tests cover every corner, from simple to complex,

Postman and Bruno now speak the same dialect! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 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 describes the main change: fixing multipart form-data file parameter export/import for Postman, which is directly supported by the changeset modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

🤖 Fix all issues with AI agents
In `@packages/bruno-converters/src/postman/postman-to-bruno.js`:
- Around line 469-471: The current conversion sets value to param.value as-is
for non-file params, allowing undefined/null to pass through and diverging from
bruno-to-postman which uses an empty string; update the non-file branch of the
value assignment so that when param.value is falsy it defaults to '' (e.g. use
the existing Array.isArray(param.value) ? param.value.join('') : param.value ||
'' logic) to ensure text params import as empty strings instead of undefined;
change the expression around the const value assignment that references param
and isFile accordingly.
🧹 Nitpick comments (1)
packages/bruno-converters/src/postman/postman-to-bruno.js (1)

467-482: Duplicated formdata processing — consider extracting a helper.

The formdata-to-multipartForm mapping at lines 467–482 is duplicated almost verbatim at lines 652–667 (example body handling). A small shared helper would eliminate this duplication.

♻️ Suggested helper extraction
+const mapFormdataToMultipartForm = (formdata) => {
+  return (formdata || []).map((param) => {
+    const isFile = param.type === 'file' || (param.type === 'default' && param.src);
+    const value = isFile
+      ? (Array.isArray(param.src) ? param.src : param.src ? [param.src] : [])
+      : (Array.isArray(param.value) ? param.value.join('') : param.value);
+
+    return {
+      uid: uuid(),
+      type: isFile ? 'file' : 'text',
+      name: param.key,
+      value,
+      description: transformDescription(param.description),
+      enabled: !param.disabled,
+      ...(param.contentType && { contentType: param.contentType })
+    };
+  });
+};

Then use it in both places:

-          each(i.request.body.formdata, (param) => {
-            // ... duplicated logic
-          });
+          brunoRequestItem.request.body.multipartForm = mapFormdataToMultipartForm(i.request.body.formdata);

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.

2 participants