-
Notifications
You must be signed in to change notification settings - Fork 135
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
Handle Invalid WSL URIs #1057
Handle Invalid WSL URIs #1057
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left suggestions in-line.
I reckon we'll also need to update this test https://github.com/hashicorp/terraform-ls/blob/2e881babf52296ec6fcf6b24ed2b3180a3b71edc/internal/langserver/handlers/initialize_test.go#L98-L117
We could also add a similar one with a WSL URI but it's probably not worth it since we're comparing error type only anyway without the extra Data field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor question/suggestion regarding the test, merge at will.
One thing I was aiming to achieve with the extra Data
field was that we'd be able to compare it more easily with just ==
or ===
on the client side. Therefore I don't fully understand the motivation behind startsWith
method here, but we can discuss it in that PR rather than here.
Even if it is decoded, further on in the uri package we make assumptions about file paths that ignore the server portion of a UNC path, resulting in terraform-ls attempting to use Ubuntu\home\james\some\path. A future PR can address that.
Yep - we can address that as part of #74
This adds another piece of logic to attempt to detect UNC WSL Uri as the workspace to open, and return a more informative error so the client can handle prompting the user. The UNC WSL Uri being passed is in the form of `\\wsl$\Ubuntu\home\james\some\path`. If the user wants to edit files in the WSL instance, they should be opening the workspace in the Remote WSL extension. When the VS Code sends the path to terraform-ls, it is urlencoded as `\\wsl%24\Ubuntu\home\james\some\path`. This fails `uri.IsURIValid`, which is incorrect because it is a valid path that needs to be decoded. Even if it is decoded, further on in the `uri` package we make assumptions about file paths that ignore the server portion of a UNC path, resulting in terraform-ls attempting to use `Ubuntu\home\james\some\path`. A future PR can address that.
This functionality has been released in v0.29.2 of the language server. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
This adds another piece of logic to attempt to detect UNC WSL Uri as the workspace to open, and return a more informative error so the client can handle prompting the user.
The UNC WSL Uri being passed is in the form of
\\wsl$\Ubuntu\home\james\some\path
. If the user wants to edit files in the WSL instance, they should be opening the workspace in the Remote WSL extension.When the VS Code sends the path to terraform-ls, it is urlencoded as
\\wsl%24\Ubuntu\home\james\some\path
. This failsuri.IsURIValid
, which is incorrect because it is a valid path that needs to be decoded. Even if it is decoded, further on in theuri
package we make assumptions about file paths that ignore the server portion of a UNC path, resulting in terraform-ls attempting to useUbuntu\home\james\some\path
. A future PR can address that.Works with, but not required, hashicorp/vscode-terraform#1219
Closes #656