Skip to content

Fix: binary body lost on importing from postman#8729

Open
sanish-bruno wants to merge 14 commits into
usebruno:mainfrom
sanish-bruno:fix/binary-body-lost-on-import
Open

Fix: binary body lost on importing from postman#8729
sanish-bruno wants to merge 14 commits into
usebruno:mainfrom
sanish-bruno:fix/binary-body-lost-on-import

Conversation

@sanish-bruno

@sanish-bruno sanish-bruno commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Jira link: https://usebruno.atlassian.net/browse/BRU-3118
Extension of #8114

Description

Postman's binary body (mode: "file") was silently dropped on import. This PR adds the missing bodyMode === 'file' branch in postman-to-bruno.js for both requests and Postman examples, mapping body.file.src to a Bruno file entry.

The content type is inferred from the file extension via mime-types (e.g. .pngimage/png, .jsonapplication/json), falling back to application/octet-stream (RFC 2046 §4.5.1) when the extension is missing or unknown. This keeps the sent Content-Type accurate instead of blanket-tagging every imported binary body as opaque bytes.

mime-types is added as a runtime dep on bruno-converters

Tests

  • Unit tests in packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js:
    • basic request import with mode: file
    • Postman example (originalRequest) import
    • extension inference for .json, .png, and .bin
    • missing src falls back cleanly to application/octet-stream
  • E2E spec + fixture under tests/import/postman/ verifying the imported body shows "File / Binary" with the file path preserved.

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

  • New Features

    • Postman imports now support binary file request bodies.
    • Imported binary bodies preserve the original file path and appear as selected.
    • File content types are inferred from extensions, with a safe fallback for unknown formats.
    • Binary bodies are also preserved when importing Postman examples.
  • Bug Fixes

    • Imports no longer fail when a binary body is provided without a source file.
  • Tests

    • Added unit and end-to-end coverage for binary body import and example preservation.
    • Improved request/example body-mode label test targeting via added UI identifiers.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c9f14789-95d2-43d7-8c3d-3c7c3f89b08c

📥 Commits

Reviewing files that changed from the base of the PR and between f3f256a and 15e6299.

📒 Files selected for processing (1)
  • tests/import/postman/import-binary-body-mode.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/import/postman/import-binary-body-mode.spec.ts

Walkthrough

Postman-to-Bruno conversion now supports file-mode request bodies and examples. Binary file paths are preserved, MIME types are inferred with a fallback, and unit plus Electron import tests cover the new behavior.

Changes

Binary body import

Layer / File(s) Summary
MIME-aware binary conversion
packages/bruno-converters/package.json, packages/bruno-converters/rollup.config.js, packages/bruno-converters/src/postman/postman-to-bruno.js
Adds mime-types, externalizes it from both builds, and converts Postman file-mode bodies into Bruno file entries for requests and examples.
Binary body UI test wiring
packages/bruno-app/src/components/BodyModeSelector/index.js, packages/bruno-app/src/components/RequestPane/RequestBody/RequestBodyMode/index.js, packages/bruno-app/src/components/ResponseExample/ResponseExampleRequestPane/ResponseExampleBodyMode/index.js, tests/utils/page/locators.ts
Adds body-mode test identifiers and shared locators for request and example assertions.
Binary import validation
packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js, tests/import/postman/fixtures/..., tests/import/postman/import-binary-body-mode.spec.ts
Tests MIME inference, missing sources, file-path preservation, and request/example UI import results.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PostmanCollection
  participant postmanToBruno
  participant mime_types
  participant BrunoRequest
  participant BrunoUI
  PostmanCollection->>postmanToBruno: provide file-mode request and example bodies
  postmanToBruno->>mime_types: infer MIME type from file extension
  mime_types-->>postmanToBruno: return MIME type or fallback
  postmanToBruno->>BrunoRequest: populate selected file entries
  BrunoRequest->>BrunoUI: render File / Binary body mode and filename
Loading

Suggested reviewers: helloanoop, lohit-bruno, naman-bruno

Poem

Binary paths take flight,
MIME blooms from .png light,
Examples follow through,
Tests guard the import queue—
Bruno reads the bytes right.

🚥 Pre-merge checks | ✅ 5
✅ 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 matches the main change: fixing Postman binary bodies being dropped during import.
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.
✨ 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.

@sanish-bruno
sanish-bruno force-pushed the fix/binary-body-lost-on-import branch from a35f614 to 69233f0 Compare July 22, 2026 13:17
@sanish-bruno
sanish-bruno marked this pull request as ready for review July 22, 2026 13:17
@sanish-bruno sanish-bruno changed the title Fix: binary body lost on import Fix: binary body lost on importing from postman Jul 22, 2026

@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

🧹 Nitpick comments (1)
tests/import/postman/import-binary-body-mode.spec.ts (1)

44-62: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Move UI selectors into page locators.

Extract the inline getByText, getByTestId, and .selected-body-mode selectors into tests/utils/page/*; use the existing locators.fileMode support for file-mode assertions.

🤖 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 `@tests/import/postman/import-binary-body-mode.spec.ts` around lines 44 - 62,
Move the inline selectors in the test steps into the appropriate page-locator
definitions under tests/utils/page: replace the request pane’s
getByText('binary-payload.bin'), the page getByTestId('request-item-chevron'),
and the .selected-body-mode locator with named locator helpers. Reuse the
existing locators.fileMode support for both file-mode assertions, and update the
test to call those locators instead of constructing selectors inline.

Sources: Coding guidelines, Path instructions

🤖 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 `@tests/import/postman/import-binary-body-mode.spec.ts`:
- Around line 7-9: Replace the test-scoped page usage in the afterAll cleanup
with afterEach or an in-test finally block, ensuring closeAllCollections
receives a valid page instance after each test. In the same test flow, replace
the inline request-item-chevron and .selected-body-mode selectors with the
existing shared locator definitions.

---

Nitpick comments:
In `@tests/import/postman/import-binary-body-mode.spec.ts`:
- Around line 44-62: Move the inline selectors in the test steps into the
appropriate page-locator definitions under tests/utils/page: replace the request
pane’s getByText('binary-payload.bin'), the page
getByTestId('request-item-chevron'), and the .selected-body-mode locator with
named locator helpers. Reuse the existing locators.fileMode support for both
file-mode assertions, and update the test to call those locators instead of
constructing selectors inline.
🪄 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: bc625387-f1b9-4637-840f-68752f31351e

📥 Commits

Reviewing files that changed from the base of the PR and between 59dfa97 and 69233f0.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • packages/bruno-converters/package.json
  • packages/bruno-converters/rollup.config.js
  • packages/bruno-converters/src/postman/postman-to-bruno.js
  • packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js
  • tests/import/postman/fixtures/postman-import-binary-body-mode.json
  • tests/import/postman/import-binary-body-mode.spec.ts

Comment thread tests/import/postman/import-binary-body-mode.spec.ts Outdated
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