Repository navigation
fix: preserve stream-backed file bodies during request interpolation - #7690
Conversation
Treat readable streams as binary request bodies in CLI and Electron so large file uploads are not serialized during JSON interpolation. Add regression coverage for stream-backed file body requests.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughIntroduces an ChangesBinary/stream body interpolation guard
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/bruno-cli/tests/runner/interpolate-vars.spec.js (1)
1-21: Consider importingjestfrom@jest/globalsfor consistency.Line 1 explicitly imports
describe,it,expectfrom@jest/globals, but line 7 uses the globaljest.fn(). While this works fine (Jest providesjestglobally), addingjestto the import would be more consistent with the explicit import pattern already established.♻️ Optional fix
-const { describe, it, expect } = require('@jest/globals'); +const { describe, it, expect, jest } = require('@jest/globals');🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/bruno-cli/tests/runner/interpolate-vars.spec.js` around lines 1 - 21, The test uses the global jest.fn() but the top imports already pull other helpers from `@jest/globals`; update the import to also bring in jest from '@jest/globals' so the file uses the same explicit import pattern, then ensure the test continues to call jest.fn() (no other changes to interpolateVars or the test logic are needed).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/bruno-cli/tests/runner/interpolate-vars.spec.js`:
- Around line 1-21: The test uses the global jest.fn() but the top imports
already pull other helpers from `@jest/globals`; update the import to also bring
in jest from '@jest/globals' so the file uses the same explicit import pattern,
then ensure the test continues to call jest.fn() (no other changes to
interpolateVars or the test logic are needed).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f9fc3840-1cfe-4966-96ad-4d137acb70c9
📒 Files selected for processing (4)
packages/bruno-cli/src/runner/interpolate-vars.jspackages/bruno-cli/tests/runner/interpolate-vars.spec.jspackages/bruno-electron/src/ipc/network/interpolate-vars.jspackages/bruno-electron/tests/network/interpolate-vars.spec.js
975c638
into
usebruno:fix/7642-stream-files-internal
|
Merged in to be polished by the maintainers |
Address #7624
Fixes a bug where
File / Binaryrequest bodies stopped sending the file contents once the selected file crossed the large-file streaming threshold.For small files, Bruno read the body as a
Bufferand sent it correctly. For larger files, Bruno switched tofs.ReadStream, and the interpolation layer incorrectly treated that stream like a JSON object, causing the request body to become the stream’s internal fields instead of the file contents.Root Cause
The request preparation path intentionally streams large files to avoid loading them fully into memory. Later, the interpolation logic only excluded
Bufferpayloads from JSON interpolation. Large file bodies wereReadStreaminstances, so they fell into the JSON interpolation branch and got serialized.This change updates the interpolation guard in both Electron and CLI to treat readable streams as binary request bodies, just like buffers.
Changes
Testing
Passed:
node --experimental-vm-modules ../../node_modules/.bin/jest --runInBand tests/network/interpolate-vars.spec.jsinpackages/bruno-electronnode --experimental-vm-modules ../../node_modules/.bin/jest --runInBand tests/runner/interpolate-vars.spec.js tests/runner/prepare-request.spec.jsinpackages/bruno-cliManual UI Verification
POSTrequest to a local echo server.BodytoFile / Binarywithapplication/json.{"fd":null,"path":...}.Contribution Checklist:
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.
Summary by CodeRabbit
Bug Fixes
Tests