-
Notifications
You must be signed in to change notification settings - Fork 269
fix(amazonq): Prevents Q UriError : Validate file URI and fallback to Path.toUri() for WSL #5960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1fa27d6
to
ffb30ef
Compare
82fc359
to
03ef99e
Compare
I added the test with @EnabledOnOs(OS.WINDOWS) so that it only runs on Windows, |
@Lee-WonJun can you run |
… Path.toUri() for WSL (aws#5960) Fix repeated UriError when Amazon Q starts with a WSL-backed workspace. We now validate the constructed file: URI and fallback to JDK’s Path.toUri() if the URI violates Rule (no authority while the path begins with //, maybe RFC 3986). This keeps legacy behavior where it’s safe, and prevents Q from rejecting the workspace folder URI
I modified the code in a different environment and later ran the check to verify it, but I think I missed reviewing the lint results. My apologies. |
…alter behavior of explain and fix buttons (#5970) * feat(amazonq): add support for CodeReview and DisplayFindings tools, alter behavior of explain and fix buttons * fix(amazonq): remove commented lines * feat(amazonq): add support for CodeReview and DisplayFindings tools, alter behavior of explain and fix buttons * fix(amazonq): remove commented lines * fix(amazonq): general code quality fixes for CodeReview and DisplayFindings tools * fix(amazonq): Prevents Q UriError : Validate file URI and fallback to Path.toUri() for WSL (#5960) Fix repeated UriError when Amazon Q starts with a WSL-backed workspace. We now validate the constructed file: URI and fallback to JDK’s Path.toUri() if the URI violates Rule (no authority while the path begins with //, maybe RFC 3986). This keeps legacy behavior where it’s safe, and prevents Q from rejecting the workspace folder URI * feat(amazonq): show the opt-in checkbox for server-side context (#5894) We need to support client-side opt-out for internal users who have workspace context server running by default. * fix(amazonq): delete AwsServerCapabilitiesProvider (#5833) It is not actually needed; we can read the values from AmazonQLspService * feat(amazonq): add support for CodeReview and DisplayFindings tools, alter behavior of explain and fix buttons * Revert "feat(amazonq): add support for CodeReview and DisplayFindings tools, alter behavior of explain and fix buttons" This reverts commit f21c028. * fix(amazonq): fix formatting issues * fix(amazonq): fix more formatting issues * fix(amazonq): fix build failures * fix(amazonq): undo unrelated change * fix(amazonq): address codeReview comments * fix(amazonq): fixing detekt errors * feat(amazonq): emit telemetry events for explainIssue and applyFix commands * feat(amazonq): add unit tests for parseFindingsMessage * fix(amazonq): fix detekt errors * fix(amazonq): fix re-direct of /review action * fix(amazonq): improve handling of case where messageId is null * fix(amazonq): Add changelog, code quality improvements * fix(amazonq): address comments * fix(amazonq): remove unused import --------- Co-authored-by: Blake Lazarine <[email protected]> Co-authored-by: Lee Won Jun <[email protected]> Co-authored-by: Jiatong Li <[email protected]> Co-authored-by: Richard Li <[email protected]> Co-authored-by: Laxman Reddy <[email protected]>
Types of changes
Description
Summary
Fix repeated
UriError
when Amazon Q starts with a WSL-backed workspace. We now validate the constructedfile:
URI and fallback to JDK’sPath.toUri()
if the URI violates Rule (no authority while the path begins with//
, maybe RFC 3986). This keeps legacy behavior where it’s safe, and prevents Q from rejecting the workspace folder URI.Related issues
Root cause
During
InitializeParams
creation,workspaceFolders
receives URIs derived fromVirtualFile
.Internally we were manually constructing file URIs like:
On WSL paths this can become:
This has no authority and a path that starts with
//
, which violates RFC 3986. Amazon Q rejects it with:Older versions reportedly worked because we used a fn in Nio:
[#5462](https://github.com/aws/aws-toolkit-jetbrains/pull/5462/files), when we switched away from the JDK-generated URI toward manual assembly.
What changed
After we build the manual
file:
URI, we inspect the resulting URI:scheme == "file"
andauthority
is empty andpath
starts with//
, it’s considered non-compliant → fallback.Fallback uses JDK normalization:
jar:
andjrt:
handling unchanged.Why fallback (and not just always
Path.toUri()
)?I personally think standardizing on
file.toPath().toAbsolutePath().normalize().toUri()
(or another well-defined canonicalization strategy) would be simpler and sufficient. However, to maintain backward compatibility, address this specific case, and respect any implicit intent behind the current manual construction, I implemented a conservative fallback: we keep the existing construction and only fall back to the JDK-generated URI when the constructed value would violate ruleTests
2025-08-09.015755.mp4
Manually verified with the plugin:
add unit test
Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.