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

Crash on diagnostics, VSCode #49

Closed
jkmnt opened this issue Aug 23, 2022 · 0 comments · Fixed by #50
Closed

Crash on diagnostics, VSCode #49

jkmnt opened this issue Aug 23, 2022 · 0 comments · Fixed by #50

Comments

@jkmnt
Copy link

jkmnt commented Aug 23, 2022

Empty jsonnet file, pressing ctrl+enter for suggestions/diagnostic after s crashes the server

{
 s
}

debug output:

time="2022-08-23T04:41:32+03:00" level=info msg="Starting the language server"
time="2022-08-23T04:41:32+03:00" level=info msg="Using tanka mode. Will fall back to the following jpaths: []"
time="2022-08-23T04:41:32+03:00" level=info msg="Initializing jsonnet-language-server version 0.7.2"
time="2022-08-23T04:41:32+03:00" level=info msg="Reading stdlib"
panic: runtime error: index out of range [9] with length 0

goroutine 51 [running]:
github.com/grafana/jsonnet-language-server/pkg/server.(*server).getEvalDiags(0xa03ec8?, 0xc00011a000)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/diagnostics.go:153 +0x629
github.com/grafana/jsonnet-language-server/pkg/server.(*server).diagnosticsLoop.func1.1.1()
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/diagnostics.go:55 +0x2a
created by github.com/grafana/jsonnet-language-server/pkg/server.(*server).diagnosticsLoop.func1.1
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/diagnostics.go:54 +0x238
[Info  - 04:41:33] Connection to server got closed. Server will restart.

VSCode 1.70.2
jsonnet-language-server 0.7.2
vscode-jsonnet: 0.2.4
windows

Looking into the sources of diagnostics.go suggests the fail of regexp match: there is match[9] access,
but match is likely to be empty.

   diag.Message = match[9]
   diag.Severity = protocol.SeverityError
julienduchesne added a commit that referenced this issue Aug 23, 2022
Fixes #49
The parsing was all wrong in some cases and was quite unsafe. This should no longer panic and it fixes a few issues with parsing
All tested now, too
julienduchesne added a commit that referenced this issue Aug 24, 2022
Fixes #49
The parsing was all wrong in some cases and was quite unsafe. This should no longer panic and it fixes a few issues with parsing
All tested now, too
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant