Skip to content

fix: normalize Windows paths for cross-platform compatibility#7185

Merged
bijin-bruno merged 2 commits intousebruno:mainfrom
naman-bruno:bugfix/workspace-path
Feb 18, 2026
Merged

fix: normalize Windows paths for cross-platform compatibility#7185
bijin-bruno merged 2 commits intousebruno:mainfrom
naman-bruno:bugfix/workspace-path

Conversation

@naman-bruno
Copy link
Collaborator

@naman-bruno naman-bruno commented Feb 18, 2026

Description

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 cross-platform path normalization so workspace collections and API specs behave consistently across Windows and non-Windows systems.
    • Ensures paths are normalized before comparisons, storage and resolution to prevent duplicate entries and mismatches.
    • Handles relative, absolute and edge-case paths uniformly to reduce errors when adding, removing or listing workspace items.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

Adds internal POSIX path normalization via a new posixifyPath helper and applies it across workspace-config path handling (collections, API specs, relative path creation, comparisons and storage) to ensure consistent, normalized paths internally. No public APIs or exported signatures changed.

Changes

Cohort / File(s) Summary
Path normalization & workspace logic
packages/bruno-electron/src/utils/workspace-config.js
Introduced posixifyPath; applied to sanitizeCollections, sanitizeSpecs, makeRelativePath, and workspace operations (add/remove/get collections & API specs). Normalized paths before comparisons, storage, and resolution; made makeRelativePath return posixified results in various cases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • bijin-bruno

Poem

Windows backslashes unwind,
Forward slashes now aligned,
Paths sing the same refrain,
Workspace tidy, cross-platform gain,
Small change — smooth road ahead ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 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: normalizing Windows paths for cross-platform compatibility, which is the core objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
packages/bruno-electron/src/utils/workspace-config.js (2)

341-341: addCollectionToWorkspace stores the path differently from addApiSpecToWorkspace.

Line 341 posixifies and stores the raw (potentially absolute) path. addApiSpecToWorkspace (line 459) runs makeRelativePath first, ensuring a relative POSIX path is stored in the YAML. For consistency, and to avoid embedding absolute Windows paths (C:/...) into workspace files (which break when the file is opened on macOS/Linux — path.isAbsolute('C:/...') returns false on POSIX), this function should do the same.

♻️ Suggested refactor
 const normalizedCollection = {
   name: collection.name.trim(),
-  path: posixifyPath(collection.path.trim())
+  path: makeRelativePath(workspacePath, collection.path.trim())
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-electron/src/utils/workspace-config.js` at line 341,
addCollectionToWorkspace currently stores collection.path after only posixifying
it, which can preserve absolute Windows paths; update addCollectionToWorkspace
to mirror addApiSpecToWorkspace by passing collection.path through
makeRelativePath(...) before posixifyPath(...) so the YAML stores a relative
POSIX path; locate the collection.path assignment in addCollectionToWorkspace
and replace the direct posixifyPath(collection.path.trim()) usage with
posixifyPath(makeRelativePath(collection.path).trim()) (or equivalent ordering
used by addApiSpecToWorkspace) to ensure consistent cross-platform relative
paths.

8-9: Consider a defensive type guard in posixifyPath.

p.replace(...) will throw if p is null, undefined, or a non-string. All current call sites are properly guarded (ternary checks / isValidCollectionEntry pre-validation), so there's no immediate risk — but a guard makes the helper self-documenting about its contract.

🛡️ Suggested guard
-const posixifyPath = (p) => p.replace(/\\/g, '/');
+const posixifyPath = (p) => (typeof p === 'string' ? p.replace(/\\/g, '/') : p);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-electron/src/utils/workspace-config.js` around lines 8 - 9,
The helper posixifyPath currently calls p.replace(...) which will throw if p is
null/undefined or not a string; add a defensive type guard at the start of
posixifyPath (e.g., check typeof p === 'string') and if the check fails return
the original value (or an empty string if you prefer) so the function never
throws on bad inputs; update any tests or callers if they rely on an exception,
and keep the function name posixifyPath unchanged so callers like
isValidCollectionEntry continue to work.
🤖 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-electron/src/utils/workspace-config.js`:
- Line 341: addCollectionToWorkspace currently stores collection.path after only
posixifying it, which can preserve absolute Windows paths; update
addCollectionToWorkspace to mirror addApiSpecToWorkspace by passing
collection.path through makeRelativePath(...) before posixifyPath(...) so the
YAML stores a relative POSIX path; locate the collection.path assignment in
addCollectionToWorkspace and replace the direct
posixifyPath(collection.path.trim()) usage with
posixifyPath(makeRelativePath(collection.path).trim()) (or equivalent ordering
used by addApiSpecToWorkspace) to ensure consistent cross-platform relative
paths.
- Around line 8-9: The helper posixifyPath currently calls p.replace(...) which
will throw if p is null/undefined or not a string; add a defensive type guard at
the start of posixifyPath (e.g., check typeof p === 'string') and if the check
fails return the original value (or an empty string if you prefer) so the
function never throws on bad inputs; update any tests or callers if they rely on
an exception, and keep the function name posixifyPath unchanged so callers like
isValidCollectionEntry continue to work.

@bijin-bruno bijin-bruno merged commit b0a88bf into usebruno:main Feb 18, 2026
8 checks passed
bijin-bruno pushed a commit that referenced this pull request Feb 18, 2026
* fix: normalize Windows paths for cross-platform compatibility in workspace

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

3 participants