Skip to content

fix: preserve stream-backed file bodies during request interpolation … - #7939

Merged
bijin-bruno merged 3 commits into
mainfrom
fix/7642-stream-files-internal
May 18, 2026
Merged

bijin-bruno merged 3 commits into
mainfrom
fix/7642-stream-files-internal

Conversation

@sid-bruno

@sid-bruno sid-bruno commented May 7, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Extends #7690
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

  • Bug Fixes

    • Improved file upload handling so stream-backed/stream-like request bodies are not altered during variable interpolation, preserving exact uploaded bytes.
  • New Features

    • Added server-side endpoints and middleware to validate byte-exact binary and JSON file uploads for testing.
  • Tests

    • Added extensive E2E and unit tests covering binary file uploads (JSON and octet-stream) and ensuring uploads remain byte-for-byte.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

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: a75baa35-3b6d-461a-b2ee-c966ea56782b

📥 Commits

Reviewing files that changed from the base of the PR and between 1ab2368 and bd2b1ec.

📒 Files selected for processing (1)
  • packages/bruno-cli/tests/runner/interpolate-vars.spec.js
✅ Files skipped from review due to trivial changes (1)
  • packages/bruno-cli/tests/runner/interpolate-vars.spec.js

Walkthrough

This PR prevents variable interpolation on binary or stream-like request bodies by adding an isBinaryRequestBody detector and using it in CLI and Electron interpolate-vars flows; it includes unit, collection, and Playwright E2E tests plus an Express test endpoint to validate byte-exact uploads.

Changes

Binary/Stream Body Interpolation Fix

Layer / File(s) Summary
CLI interpolation fix for stream bodies
packages/bruno-cli/src/runner/interpolate-vars.js, packages/bruno-cli/tests/runner/interpolate-vars.spec.js
Adds isBinaryRequestBody helper that detects Buffer or stream-like (.pipe) request bodies, updates the JSON-body interpolation gate to skip binary/stream payloads, and tests that stream objects remain unmutated.
Electron interpolation fix for stream bodies
packages/bruno-electron/src/ipc/network/interpolate-vars.js, packages/bruno-electron/tests/network/interpolate-vars.spec.js
Mirrors the CLI fix with the same stream-detection helper and guard, with test coverage for file-mode stream-backed JSON bodies remaining unchanged during interpolation.
Express test server for binary uploads
packages/bruno-tests/src/file-binary/index.js, packages/bruno-tests/src/index.js
Creates a raw-body-parsing Express router endpoint that computes and returns byte-exact upload metadata (size, SHA-256, stream-signature detection), mounted before global body parsers to preserve raw bytes.
Bruno test collection definitions
packages/bruno-tests/collection/file-binary/binary-upload-json.bru, packages/bruno-tests/collection/file-binary/binary-upload-octet-stream.bru
Defines two HTTP test scenarios validating byte-exact uploads and absence of serialized Node stream wrapping via assertions on bytesReceived, sha256, and looksLikeSerializedNodeStream response fields.
Playwright E2E regression tests
tests/request/binary-file/binary-file-upload.spec.ts
Adds an end-to-end test suite that stubs Electron's file picker, configures File/Binary body mode through the UI, sends JSON and octet-stream payloads, and verifies byte-exact delivery without Node stream serialization artifacts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • usebruno/bruno#7690: Implements the same isBinaryRequestBody helper and interpolation guard update across CLI and Electron with matching regression test patterns.
  • usebruno/bruno#6922: Earlier change that skipped interpolation for Buffer request bodies; this PR generalizes that behavior to include stream-like bodies.

Suggested reviewers

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

✨ A stream flows true, no JSON in sight,
Binary bodies skip interpolation's might,
From CLI to Electron, bytes stay tight,
Tests confirm hashes and sizes right,
Uploads arrive intact — let devs delight! 🎉

🚥 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 accurately summarizes the main change: adding support for preserving stream-backed file bodies during request interpolation, which is the core objective across all modified files.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/7642-stream-files-internal

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.

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

CLI Test Results

  1 files  ±0  211 suites  ±0   1m 3s ⏱️ +18s
592 tests ±0  592 ✅ ±0  0 💤 ±0  0 ❌ ±0 
705 runs  ±0  698 ✅ ±0  7 💤 ±0  0 ❌ ±0 

Results for commit 975c638. ± Comparison against base commit f8bf146.

@pull-request-size pull-request-size Bot added size/L and removed size/M labels May 15, 2026
@sid-bruno
sid-bruno marked this pull request as ready for review May 15, 2026 08:18
Copilot AI review requested due to automatic review settings May 15, 2026 08:18

Copilot AI 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.

Pull request overview

This PR preserves stream-backed file request bodies during interpolation and adds regression coverage across Electron, CLI, e2e, and the Bruno test server/collection.

Changes:

  • Adds binary request body detection for Buffers and stream-like payloads in Electron and CLI interpolation.
  • Adds unit/e2e tests for stream-backed JSON file bodies.
  • Adds Bruno test-server endpoints and collection requests for raw file/binary upload verification.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/bruno-electron/src/ipc/network/interpolate-vars.js Skips JSON interpolation for binary/stream request bodies.
packages/bruno-cli/src/runner/interpolate-vars.js Mirrors binary/stream interpolation guard in CLI runner.
packages/bruno-electron/tests/network/interpolate-vars.spec.js Adds Electron interpolation regression test.
packages/bruno-cli/tests/runner/interpolate-vars.spec.js Adds CLI interpolation regression test.
tests/request/binary-file/binary-file-upload.spec.ts Adds Electron e2e file/binary upload coverage.
packages/bruno-tests/src/index.js Mounts the file-binary test router before global body parsers.
packages/bruno-tests/src/file-binary/index.js Adds raw upload verification endpoints.
packages/bruno-tests/collection/file-binary/*.bru Adds Bruno collection requests/assertions for binary upload tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented May 15, 2026 •

Copy link
Copy Markdown

CLI Test Results (Linux)

  1 files  213 suites   44s ⏱️
601 tests 601 ✅ 0 💤 0 ❌
714 runs  707 ✅ 7 💤 0 ❌

Results for commit bd2b1ec.

♻️ This comment has been updated with latest results.

@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: 2

🤖 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-cli/tests/runner/interpolate-vars.spec.js`:
- Line 20: The closing brace line "});" in tests/runner/interpolate-vars.spec.js
is indented with 3 spaces and fails ESLint; fix it by reducing the indentation
to 2 spaces so the closing "});" aligns with the opening block (the test
suite/describe block in interpolate-vars.spec.js).

In `@tests/request/binary-file/binary-file-upload.spec.ts`:
- Line 51: The inline comment next to the LARGE_JSON_BYTES constant is
inconsistent (it says "25 MiB" while the value is 80 * 1024 * 1024); update the
comment to correctly describe the allocated size (e.g., "80 MiB > 20 MiB
threshold") so the comment matches the LARGE_JSON_BYTES value.
🪄 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: 9abfd6ea-b749-4768-afee-74a5c2c71611

📥 Commits

Reviewing files that changed from the base of the PR and between f8bf146 and 1ab2368.

📒 Files selected for processing (9)
  • packages/bruno-cli/src/runner/interpolate-vars.js
  • packages/bruno-cli/tests/runner/interpolate-vars.spec.js
  • packages/bruno-electron/src/ipc/network/interpolate-vars.js
  • packages/bruno-electron/tests/network/interpolate-vars.spec.js
  • packages/bruno-tests/collection/file-binary/binary-upload-json.bru
  • packages/bruno-tests/collection/file-binary/binary-upload-octet-stream.bru
  • packages/bruno-tests/src/file-binary/index.js
  • packages/bruno-tests/src/index.js
  • tests/request/binary-file/binary-file-upload.spec.ts

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.

5 participants