fix: normalizes the path to POSIX format#8737
Conversation
WalkthroughFile paths selected in the GUI and processed by the CLI are normalized for cross-platform request uploads. Windows separators are converted before relative-path storage, path resolution, filename extraction, and stream creation. ChangesFile upload path normalization
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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/src/runner/prepare-request.js (1)
409-410: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd regression coverage for Windows-style relative paths.
Test
relative\\path\\file.txtin both file-body preparation and multipart form-data creation, asserting it resolves undercollectionPathasrelative/path/file.txtbefore file access. This protects the cross-layer contract from future drift.
packages/bruno-cli/src/runner/prepare-request.js#L409-L410: coverreadFileSyncandcreateReadStream.packages/bruno-cli/src/utils/form-data.js#L29-L30: cover multipartcreateReadStream.🤖 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 `@packages/bruno-cli/src/runner/prepare-request.js` around lines 409 - 410, Add regression tests for Windows-style relative paths at packages/bruno-cli/src/runner/prepare-request.js#L409-L410, covering both readFileSync for file bodies and createReadStream for multipart data, and assert each resolves under collectionPath as relative/path/file.txt before access. Also add coverage at packages/bruno-cli/src/utils/form-data.js#L29-L30 for multipart createReadStream, verifying the normalized POSIX path is used.
🤖 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.
Nitpick comments:
In `@packages/bruno-cli/src/runner/prepare-request.js`:
- Around line 409-410: Add regression tests for Windows-style relative paths at
packages/bruno-cli/src/runner/prepare-request.js#L409-L410, covering both
readFileSync for file bodies and createReadStream for multipart data, and assert
each resolves under collectionPath as relative/path/file.txt before access. Also
add coverage at packages/bruno-cli/src/utils/form-data.js#L29-L30 for multipart
createReadStream, verifying the normalized POSIX path is used.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9c2f45b8-7239-4f8e-bd15-14d02581bc82
📒 Files selected for processing (2)
packages/bruno-cli/src/runner/prepare-request.jspackages/bruno-cli/src/utils/form-data.js
There was a problem hiding this comment.
Pull request overview
This PR targets issue #8728 by normalizing Windows-style backslash file paths (stored in collections created on Windows) so that file uploads work when running the same collection on Linux CI via bruno-cli.
Changes:
- Normalize multipart form-data file paths before resolving them against
collectionPath. - Normalize “file body” upload paths before resolving them against
collectionPath.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/bruno-cli/src/utils/form-data.js | Normalizes multipart file paths before joining with the collection root. |
| packages/bruno-cli/src/runner/prepare-request.js | Normalizes single file-body upload paths before joining with the collection root. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Normalize to POSIX format for cross-platform compatibility | ||
| filePath = path.posix.normalize(filePath.replace(/\\/g, '/')); | ||
| if (!path.isAbsolute(filePath)) { | ||
| filePath = path.join(collectionPath, filePath); | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…m/Apoorv012/bruno into bugfix/windows-path-compatibility
Description
Issue Resolved: #8728
It was using
path.join()which was joining windows pathcurrent/directoryandrelative\path\file.txtresulting incurrent/directory/relative\path\file.txtand causing file not found error.So, I first normalized the path to POSIX format, and then joined them.
Edit: Normalized file paths to POSIX format (forward slashes) at save time in the GUI as well. So this fixes the issue at source.
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.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit