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

x/tools/gopls: panic on invalid filename #49223

Closed
kerma opened this issue Oct 29, 2021 · 2 comments
Closed

x/tools/gopls: panic on invalid filename #49223

kerma opened this issue Oct 29, 2021 · 2 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@kerma
Copy link

kerma commented Oct 29, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16.6 darwin/amd64

$ gopls version
golang.org/x/tools/gopls v0.7.3
    golang.org/x/tools/gopls@v0.7.3 h1:Lru57ht8vtDMouRskFC085VAjBAZRAISd/lwvwOOV0Q=

What did you do?

Used gopls via vim-go. Opened up one of the fugitive.vim plugin diff views, a textDocument/definition request was sent which crashed gopls.

What did you expect to see?

No panic, but ResponseMessage with ResponseError

What did you see instead?

The following request was sent to gopls:

Content-Length: 248
{"method": "textDocument/definition", "jsonrpc": "2.0", "id": 596, "params": {"textDocument": 
   {"uri": "fugitive%3A///Users/user/src/mm/ems/.git//0/pkg/domain/treasury/provider.go"}, 
   "position": {"character": 18, "line": 0}}}

This resulted in gopls panic:

panic: parse "fugitive%3A///Users/user/src/mm/ems/.git//0/pkg/domain/treasury/provider.go": 
invalid URI for request

I think that regressions was introduced in v0.7.1:
https://github.com/golang/tools/blob/e08545a2921d85f5ac0c3f1dde9997511237c957/internal/lsp/definition.go#L16

To be clear, I don't expect gopls to be able to handle things outside of defined URI scheme, but valid payload with invalid values should not result in panic.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Oct 29, 2021
@gopherbot gopherbot added this to the Unreleased milestone Oct 29, 2021
@findleyr
Copy link
Contributor

Thanks for the report, and investigation. You are correct about the root cause; fix incoming.

@gopherbot
Copy link

Change https://golang.org/cl/359734 mentions this issue: internal/lsp: check for invalid URIs in definition

@findleyr findleyr modified the milestones: Unreleased, gopls/v0.7.4 Dec 15, 2021
@golang golang locked and limited conversation to collaborators Dec 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants