Skip to content

fix: find a WSL file whose path has a space from its URI - #2355

Merged
lagergren merged 3 commits into
redhat-developer:mainfrom
d-biehl:fix/2354-wsl-path-with-space
Nov 30, 2026
Merged

lagergren merged 3 commits into
redhat-developer:mainfrom
d-biehl:fix/2354-wsl-path-with-space

Conversation

@d-biehl

@d-biehl d-biehl commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #2354.

In a project inside WSL whose path contains a space, LSP4IJ doesn't find the file of a URI it built itself, so the diagnostics for these files don't appear. UriConverterManager.findResourceFor URL-decodes every URI that contains % before it asks the converters, and WslUriConverter.findResourceFor parsed the decoded string with new URI(uri), which rejects the space.

WslUriConverter now splits the URI into authority and path by hand, in the new toUncPath, which works for the decoded string. The decoding in the manager stays as it is.

The new tests in WslUriConverterTest convert WSL URIs to UNC paths, among them the URIs that toUri creates for a path with a space and for the non-ASCII path of #1794, decoded as the manager does. Before the change, new URI threw URISyntaxException for such a decoded string, as in the issue. Locally, on Linux, ./gradlew check passes (2,658 tests).

UriConverterManager decodes a URI that contains '%' before it asks the
converters, and WslUriConverter parsed the decoded string with new URI,
which rejects a space. It now splits the URI by hand, so the files below
a WSL path with a space are found.

Fixes redhat-developer#2354

Signed-off-by: Daniel Biehl <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 28, 2026 22:08
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved Windows resource lookup for files in WSL environments. Locations using either wsl$ or wsl.localhost are converted to Windows-compatible paths.
    • Paths containing spaces and non-ASCII characters are supported. Non-WSL file locations continue to be handled separately.
  • Documentation
    • Corrected the WSL URI example to use a single separator between home and dev.

On Windows, WslUriConverter converts supported WSL URIs to UNC paths before resource lookup. Tests cover both supported prefixes, decoded spaces, non-ASCII paths, and non-WSL URIs.

Changes: WSL URI conversion

Layer / File(s) Summary
Convert WSL URIs and look up resources
src/main/java/com/redhat/devtools/lsp4ij/internal/uri/WslUriConverter.java, src/test/java/com/redhat/devtools/lsp4ij/internal/uri/WslUriConverterTest.java
findResourceFor uses toUncPath on Windows and looks up a resource when conversion returns a path. toUncPath recognizes file://wsl$/ and file://wsl.localhost/ and replaces forward slashes with backslashes. Tests cover both prefixes, decoded paths with spaces, non-ASCII paths, and non-WSL URIs.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: tim-sh, angelozerr

Merge Risk: Minimal · up to 31a7a

This change lets files in WSL projects whose paths contain spaces resolve correctly, so diagnostics should appear for them. No merge-blocking risk is evident from the supplied review context.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: WSL file lookup fails when the path contains a space, and the fix is in how the URI is converted. It matches the summary, which adds toUncPath to replace new URI parsi…
Description check Passed The description states the bug (WSL project path with a space, URI decoded by UriConverterManager, new URI rejects the space), the fix (toUncPath splits authority and path manually), and the new tests…
Linked Issues check Passed Issue #2354 requires that a WSL URI whose path contains a space, such as file://wsl.localhost/Ubuntu-26.04/home/daniel/robot%20project/..., resolves after UriConverterManager.findResourceFor decodes i…
Out of Scope Changes check Passed The supplied summary lists changes only in WslUriConverter (new toUncPath, findResourceFor delegating to it, Javadoc updates, removal of the URI parse and its warning, and a corrected path example in …
Full details: Title check

Explanation

The title names the main change: WSL file lookup fails when the path contains a space, and the fix is in how the URI is converted. It matches the summary, which adds toUncPath to replace new URI parsing for decoded URIs.

Full details: Description check

Explanation

The description states the bug (WSL project path with a space, URI decoded by UriConverterManager, new URI rejects the space), the fix (toUncPath splits authority and path manually), and the new tests in WslUriConverterTest. It is on-topic and specific.

Full details: Linked Issues check

Explanation

Issue #2354 requires that a WSL URI whose path contains a space, such as file://wsl.localhost/Ubuntu-26.04/home/daniel/robot%20project/..., resolves after UriConverterManager.findResourceFor decodes it. I re-read WslUriConverter.java at head. On Windows, findResourceFor calls the static toUncPath(uri) and passes the result to LocalFileSystem.findFileByPath. toUncPath returns null unless the URI starts with file://wsl$/ or file://wsl.localhost/. For other URIs, it splits the authority from the path at the first '/' after the scheme, keeps the decoded space, and replaces '/' with '\'. The new Java code no longer calls new URI(uri) on the decoded string, so the URISyntaxException path from the issue is gone. The tests in WslUriConverterTest cover wsl.localhost and wsl$ conversion, the decoded space-path case, the non-ASCII path from #1794, and a non-WSL URI returning null. Limits: the Windows-only branch of findResourceFor is not exercised by the tests, which call toUncPath directly. The head-versus-base diff could not be read because changed blobs are missing from the checkout, so the change set relies on the supplied summary and the file content at head.

Full details: Out of Scope Changes check

Explanation

The supplied summary lists changes only in WslUriConverter (new toUncPath, findResourceFor delegating to it, Javadoc updates, removal of the URI parse and its warning, and a corrected path example in documentation) and WslUriConverterTest (new toUncPath tests). The file at head matches this description. The toUri method is unchanged. The tests and the removed parse directly support the fix for #2354 and the #1794 non-ASCII regression check. No unrelated files or behavior changes were identified. The head-versus-base diff could not be read, so this conclusion relies on the supplied summary.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 25c7de70-082f-40d7-a1e1-f77a9c4a18c0
Commits

Reviewing files that changed from the base of the PR and between 425dea1 and 31a7a17.

Files selected for processing: 1

  • src/main/java/com/redhat/devtools/lsp4ij/internal/uri/WslUriConverter.java
Files skipped from review as they are similar to previous changes: 1

  • src/main/java/com/redhat/devtools/lsp4ij/internal/uri/WslUriConverter.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the WSL URI conversion change.

No open issues 🎉

What changed in this PR

Fixes WSL file lookup for paths containing spaces (#2354), allowing diagnostics to resolve files from URIs already decoded by UriConverterManager.

Changes:

  • Replaces strict URI parsing with a helper that splits decoded WSL URIs into UNC paths.
  • Adds tests for both WSL host formats, spaces, non-ASCII paths, and non-WSL URIs.
File Description
src/​test/​java/​com/​redhat/​devtools/​lsp4ij/​internal/​uri/​WslUriConverterTest.java Adds UNC conversion tests, including decoded URI regressions.
src/​main/​java/​com/​redhat/​devtools/​lsp4ij/​internal/​uri/​WslUriConverter.java Adds toUncPath and uses it for Windows file lookup.

Review effort: Balanced

@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.63%. Comparing base (0665956) to head (31a7a17).
⚠️ Report is 87 commits behind head on main.

Files with missing lines Patch % Lines
.../devtools/lsp4ij/internal/uri/WslUriConverter.java 63.63% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2355      +/-   ##
==========================================
+ Coverage   58.63%   59.63%   +0.99%     
==========================================
  Files         849      857       +8     
  Lines       36719    37282     +563     
  Branches     7609     5864    -1745     
==========================================
+ Hits        21530    22232     +702     
+ Misses      12187    11991     -196     
- Partials     3002     3059      +57     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren lagergren added the bug Something isn't working label Nov 28, 2026
@lagergren lagergren added this to the 0.30.3 milestone Nov 28, 2026

@lagergren lagergren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for the fix, @d-biehl, and for the clear analysis in #2354! The tests that decode the URIs the way the manager does are a nice touch.

The change looks good to me, with one typo in a Javadoc example, below. It's on the 0.30.3 milestone, which opens once 0.30.2 is released next week.

Java reads `\u` as the start of a Unicode escape also in comments, so the
examples wrote `home\\user`. With `home\dev` they read as plain paths.

Signed-off-by: Daniel Biehl <[email protected]>
lagergren added a commit that referenced this pull request Nov 30, 2026
…test has listed the temp directory

Each test built its JAR in a new folder of the temp directory and looked it up without a refresh. Once another test of
the same JVM had listed the temp directory, the VFS didn't look for the new folder on disk, and the first
assertTemplates failed, as on IntelliJ 2025.3 in a CI run of #2355. The first build of a test's JAR is now looked up
with a refresh, as the IDE knows the JAR from which it read the templates at its previous start.

Fixes #2360

@lagergren lagergren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One small follow-up to the rename: the two conversion examples still have home/user on their URI side, so they now convert home/user into home\dev and back. The suggestions below make both sides home/dev.

@lagergren lagergren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, @d-biehl, both examples now read home/dev on both sides, and the \u explanation was a good catch. I'll squash-merge it, so that the fix and its two Javadoc follow-ups make one line in the release notes.

@lagergren
lagergren merged commit b799277 into redhat-developer:main Nov 30, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WSL files whose path has a space are not found from their URI: UriConverterManager.findResourceFor decodes before WslUriConverter parses

3 participants