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 unnamed output block #611

Closed
polynomialspace opened this issue Aug 5, 2021 · 2 comments · Fixed by #612
Closed

Crash on unnamed output block #611

polynomialspace opened this issue Aug 5, 2021 · 2 comments · Fixed by #612
Labels
bug Something isn't working

Comments

@polynomialspace
Copy link

VS Code Version

Version: 1.58.2
Commit: c3f126316369cd610563c75b1b1725e0679adfb3
Date: 2021-07-14T22:10:12.490Z
Electron: 12.0.13
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Darwin arm64 20.6.0

Extension Version

hashicorp.terraform v2.14.0

Language Server Version

Launching language server: /Users/ash/.vscode/extensions/hashicorp.terraform-2.14.0/lsp/terraform-ls serve
2021/08/04 20:28:02 serve_command.go:150: Starting terraform-ls 0.20.1

Terraform Version

Terraform v1.0.3
on darwin_arm64

Steps To Reproduce

Type output {} and maybe invoke a code format

Expected Behavior

Throw a formatting error probably

Actual Behavior

Crash 😢

Additional context

Relevant part of log:

panic: runtime error: index out of range [0] with length 0

goroutine 70 [running]:
github.com/hashicorp/hcl-lang/decoder.resolveBlockAddress(0x140096185a0, 0x1400ffb5400, 0x0, 0x100f7c3b0, 0x0, 0x0)
	github.com/hashicorp/hcl-lang@v0.0.0-20210803155453-7c098e4940bc/decoder/reference_targets.go:1233 +0x570
github.com/hashicorp/hcl-lang/decoder.(*Decoder).decodeReferenceTargetsForBody(0x1400ffa7d28, 0x1400ffaa210, 0x0, 0x1400ffac100, 0x0, 0x0, 0x100f7c3b0)
	github.com/hashicorp/hcl-lang@v0.0.0-20210803155453-7c098e4940bc/decoder/reference_targets.go:362 +0x37c
github.com/hashicorp/hcl-lang/decoder.(*Decoder).CollectReferenceTargets(0x1400ffa7d28, 0x0, 0x0, 0x0, 0x0, 0x0)
	github.com/hashicorp/hcl-lang@v0.0.0-20210803155453-7c098e4940bc/decoder/reference_targets.go:321 +0x1c4
github.com/hashicorp/terraform-ls/internal/terraform/module.DecodeReferenceTargets(0x140000a81a0, 0x100c60628, 0x140000a81c0, 0x1400635a0c7, 0x14, 0x2, 0x1400d50e000)
	github.com/hashicorp/terraform-ls/internal/terraform/module/module_ops.go:375 +0x2bc
github.com/hashicorp/terraform-ls/internal/terraform/module.(*moduleLoader).executeModuleOp(0x1400d4baf50, 0x100c6b118, 0x1400d507900, 0x1400635a0c7, 0x14, 0x7, 0x0, 0x1400ffcafc0)
	github.com/hashicorp/terraform-ls/internal/terraform/module/module_loader.go:186 +0x784
github.com/hashicorp/terraform-ls/internal/terraform/module.(*moduleLoader).run.func1(0x100c6b118, 0x1400d507900, 0x1400635a0c7, 0x14, 0x7, 0x0, 0x1400ffcafc0, 0x1400d4baf50)
	github.com/hashicorp/terraform-ls/internal/terraform/module/module_loader.go:101 +0x54
created by github.com/hashicorp/terraform-ls/internal/terraform/module.(*moduleLoader).run
	github.com/hashicorp/terraform-ls/internal/terraform/module/module_loader.go:100 +0x16c
[Error - 8:50:23 PM] Connection to server got closed. Server will not be restarted.

image

This happened in a larger module and it took me a while to spot because it's hard to catch the formatting error when the formatter crashes, which is a pretty funny scenario really.

@radeksimko radeksimko changed the title Crash on unnamed output block Crash on unnamed output block Aug 5, 2021
@radeksimko radeksimko transferred this issue from hashicorp/vscode-terraform Aug 5, 2021
@radeksimko
Copy link
Member

Thank you for the detailed bug report.

This will be fixed as part of #612 which should be part of an upcoming release.

@radeksimko radeksimko added the bug Something isn't working label Aug 5, 2021
@github-actions
Copy link

github-actions bot commented Sep 5, 2021

I'm going to lock this issue 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 similar to this, 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 Sep 5, 2021
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 a pull request may close this issue.

2 participants