Skip to content
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

fix: avoid crash on invalid URIs #969

Merged
merged 1 commit into from
Jun 27, 2022
Merged

fix: avoid crash on invalid URIs #969

merged 1 commit into from
Jun 27, 2022

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Jun 27, 2022

The language server isn't able to do anything with invalid/unsupported URIs, such as the ones listed in hashicorp/vscode-terraform#1159

There's a broader question of whether these URIs should even be send to LS. Given that the known majority of such URIs come from VS Code, I created a separate ticket hashicorp/vscode-terraform#1159 to discuss the problem there.

Prior to this patch it would crash when encountered such a URI during initialize, textDocument/didOpen or workspace/didChangeWorkspaceFolders, as reported in #959

We already handle this gracefully in custom commands:

if !uri.IsURIValid(modUri) {
return response, fmt.Errorf("URI %q is not valid", modUri)
}

if !uri.IsURIValid(modUri) {
return nil, fmt.Errorf("URI %q is not valid", modUri)
}

if !uri.IsURIValid(modUri) {
return response, fmt.Errorf("URI %q is not valid", modUri)
}

if !uri.IsURIValid(dirUri) {
return nil, fmt.Errorf("URI %q is not valid", dirUri)
}

if !uri.IsURIValid(dirUri) {
return nil, fmt.Errorf("URI %q is not valid", dirUri)
}

@radeksimko radeksimko added the bug Something isn't working label Jun 27, 2022
@radeksimko radeksimko marked this pull request as ready for review June 27, 2022 09:49
@radeksimko radeksimko requested a review from a team as a code owner June 27, 2022 09:49
@radeksimko radeksimko added this to the v0.29.0 milestone Jun 27, 2022
@radeksimko radeksimko self-assigned this Jun 27, 2022
Copy link
Contributor

@jpogran jpogran left a comment

Choose a reason for hiding this comment

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

Until we figure out why we're getting so many non file URIs I think this is a great stop-gap for improving UX

@github-actions
Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants