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

panic: runtime error: index out of range #81

Closed
yvesjans opened this issue May 19, 2024 · 3 comments · Fixed by #83 or #88
Closed

panic: runtime error: index out of range #81

yvesjans opened this issue May 19, 2024 · 3 comments · Fixed by #83 or #88

Comments

@yvesjans
Copy link

yvesjans commented May 19, 2024

Recently I started experiencing helm-ls crashing when using specific helm charts using a range in the template. We do this for example to generate multiple deployments (e.g. spot vs ondemand nodes)

[ERROR][2024-05-19 14:13:55] .../vim/lsp/rpc.lua:770    "rpc"   "helm_ls"       "stderr"        "panic: runtime error: index out of range [0] with length 0\n\ngoroutine 28 [running]:\n"
[ERROR][2024-05-19 14:13:55] .../vim/lsp/rpc.lua:770    "rpc"   "helm_ls"       "stderr"        "github.com/mrjosh/helm-ls/internal/language_features.(*TemplateContextFeature).Hover(0x14000616040)\n\tgit.luolix.top/mrjosh/helm-ls/internal/language_features/template_context.go:86 +0x568\ngit.luolix.top/mrjosh/helm-ls/internal/handler.(*langHandler).Hover(0x140004ae0c0, {0x102546c70, 0x14000428000}, 0x14000558000)\n\tgit.luolix.top/mrjosh/helm-ls/internal/handler/hover.go:31 +0x284\ngo.lsp.dev/protocol.serverDispatch({0x102546c70, 0x14000428000}, {0x102558e28, 0x140004ae0c0}, 0x14000550060, {0x102546df8, 0x140005c8180})\n\tgo.lsp.dev/protocol@v0.12.0/server.go:434 +0x1bb0\ngo.lsp.dev/protocol.NewServer.ServerHandler.func1({0x102546c70, 0x14000428000}, 0x14000550060, {0x102546df8, 0x140005c8180})\n\tgo.lsp.dev/protocol@v0.12.0/server.go:36 +0x6c\ngo.lsp.dev/protocol.Handlers.ReplyHandler.func1({0x102546c70, 0x14000428000}, 0x140005ba060, {0x102546df8?, 0x140005c8180?})\n\tgo.lsp.dev/jsonrpc2@v0.10.0/handler.go:35 +0xdc"
[ERROR][2024-05-19 14:13:55] .../vim/lsp/rpc.lua:770    "rpc"   "helm_ls"       "stderr"        "\ngo.lsp.dev/protocol.Handlers.AsyncHandler.func2.2()\n\tgo.lsp.dev/jsonrpc2@v0.10.0/handler.go:114 +0x78\ncreated by go.lsp.dev/protocol.Handlers.AsyncHandler.func2 in goroutine 8\n\tgo.lsp.dev/jsonrpc2@v0.10.0/handler.go:112 +0x194\n"

Chart to reproduce attached
helm-lsp-repro.tar.gz

Open templates/deployment.yaml and hover doc on $config.hpa.minReplicas makes helm-ls panic

.local/share/nvim/mason/bin/helm_ls version
Helm-ls version: master
Git commit: aab553b
Build type: Release
Build time: 2024-05-09_02:37:42PM
Golang: go1.21.5
Compiled by: fv-az529-500

nvim --version
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713773202
Run "nvim -V1 -v" for more info
@qvalentin
Copy link
Collaborator

Thanks for reporting.
Using variable in the template context is currently not supported. E.g. something like this:

{{- $root := . -}}
{{- $root.Values.deployments }}

wont' give a result. But it should not crash the lsp anymore.

@qvalentin
Copy link
Collaborator

I opened #84 for the general support of this syntax.

@yvesjans
Copy link
Author

Thanks for the quick fix! All working again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants