Skip to content

fix: normalizes the path to POSIX format#8737

Open
Apoorv012 wants to merge 6 commits into
usebruno:mainfrom
Apoorv012:bugfix/windows-path-compatibility
Open

fix: normalizes the path to POSIX format#8737
Apoorv012 wants to merge 6 commits into
usebruno:mainfrom
Apoorv012:bugfix/windows-path-compatibility

Conversation

@Apoorv012

@Apoorv012 Apoorv012 commented Jul 22, 2026

Copy link
Copy Markdown

Description

Issue Resolved: #8728

It was using path.join() which was joining windows path current/directory and relative\path\file.txt resulting in current/directory/relative\path\file.txt and 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:

  • 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 reliability across operating systems by normalizing user-provided file paths before validation and upload preparation.
    • Upload handling now consistently supports Windows-style backslashes and trimmed paths, reducing failures from mixed environment references.
    • File path selection in multipart/form requests now derives paths relative to the collection base more consistently, improving duplicate detection and updates.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

File 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.

Changes

File upload path normalization

Layer / File(s) Summary
Normalize uploaded file paths
packages/bruno-app/src/components/RequestPane/FileBody/index.js, packages/bruno-app/src/components/RequestPane/MultipartFormParams/index.js, packages/bruno-cli/src/runner/prepare-request.js, packages/bruno-cli/src/utils/form-data.js
GUI file inputs and multipart selections store normalized paths; CLI request preparation and form-data creation normalize paths before resolution and file access.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: helloanoop, bijin-bruno

Poem

Backslashes turn and paths align,
Files cross platforms line by line.
Streams open where they belong,
Requests carry paths along.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR addresses #8728 by normalizing Windows-style file paths before joining or reading them, matching the cross-platform fix requirement.
Out of Scope Changes check ✅ Passed The added app-side path normalization supports the same file-path bug fix and does not appear unrelated to the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: normalizing file paths to POSIX format for cross-platform handling.
✨ 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.

@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.

🧹 Nitpick comments (1)
packages/bruno-cli/src/runner/prepare-request.js (1)

409-410: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for Windows-style relative paths.

Test relative\\path\\file.txt in both file-body preparation and multipart form-data creation, asserting it resolves under collectionPath as relative/path/file.txt before file access. This protects the cross-layer contract from future drift.

  • packages/bruno-cli/src/runner/prepare-request.js#L409-L410: cover readFileSync and createReadStream.
  • packages/bruno-cli/src/utils/form-data.js#L29-L30: cover multipart createReadStream.
🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4f02e61 and ac67248.

📒 Files selected for processing (2)
  • packages/bruno-cli/src/runner/prepare-request.js
  • packages/bruno-cli/src/utils/form-data.js

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

Comment thread packages/bruno-cli/src/utils/form-data.js Outdated
Comment on lines 409 to 413
// Normalize to POSIX format for cross-platform compatibility
filePath = path.posix.normalize(filePath.replace(/\\/g, '/'));
if (!path.isAbsolute(filePath)) {
filePath = path.join(collectionPath, filePath);
}
Apoorv012 and others added 3 commits July 22, 2026 23:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@PiotrMachowski

Copy link
Copy Markdown

#8728 (comment)

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.

Files added to the request body on Windows GUI will not work when running collection on Linux CI

3 participants