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

terraform-ls panics with: value is unknown #447

Closed
courteouselk opened this issue Mar 26, 2021 · 6 comments · Fixed by #452
Closed

terraform-ls panics with: value is unknown #447

courteouselk opened this issue Mar 26, 2021 · 6 comments · Fixed by #452
Labels
bug Something isn't working

Comments

@courteouselk
Copy link

terraform-ls started to crash on my machine.

Launching language server: /Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/lsp/terraform-ls serve -tf-exec=/usr/local/bin/terraform for folder: file:///Users/REDACTED/
2021/03/26 13:58:10 serve_command.go:134: Terraform exec path set to "/usr/local/bin/terraform"
2021/03/26 13:58:10 serve_command.go:137: Starting terraform-ls 0.15.0
2021/03/26 13:58:10 service.go:71: Preparing new session ...
2021/03/26 13:58:10 watcher.go:219: watching for changes ...
2021/03/26 13:58:10 langserver.go:69: Starting server (pid 73209) ...
...
2021/03/26 14:00:07 server.go:443: Posting server call "window/showMessageRequest" {"type":3,"message":"No schema found for \"terraform/_modules/v2-frontend-ingress\". Functionality may be limited. You may need to run terraform init.","actions":[{"title":"terraform init"}]}
2021/03/26 14:00:07 server.go:174: Processing 1 requests
2021/03/26 14:00:07 server.go:265: Checking request for "textDocument/documentLink": {"textDocument":{"uri":"file:///Users/REDACTED/terraform/_modules/v2-frontend-ingress/dns.tf"}}
panic: value is unknown

goroutine 66 [running]:
github.com/zclconf/go-cty/cty.Value.AsString(0x1867d90, 0xc00002ac3b, 0x1524ac0, 0x1b4fd60, 0x1524a00, 0x1b4fd60)
	github.com/zclconf/go-cty@v1.8.0/cty/value_ops.go:1257 +0x165
github.com/hashicorp/hcl-lang/decoder.nestedSymbolsForExpr(0x1867a80, 0xc0005ee000, 0xc0005ee000, 0x1867a80, 0xc0005ee000)
	github.com/hashicorp/hcl-lang@v0.0.0-20210311200725-da0537032422/decoder/symbols.go:134 +0x23e
github.com/hashicorp/hcl-lang/decoder.symbolsForBody(0xc0001782c0, 0xc0005b2c60, 0xc0004ee9a0, 0x1b50058)
	github.com/hashicorp/hcl-lang@v0.0.0-20210311200725-da0537032422/decoder/symbols.go:72 +0x1f6
github.com/hashicorp/hcl-lang/decoder.symbolsForBody(0xc0001789a0, 0xc00052c066, 0x6, 0xc00052a9c0)
	github.com/hashicorp/hcl-lang@v0.0.0-20210311200725-da0537032422/decoder/symbols.go:80 +0x5e5
github.com/hashicorp/hcl-lang/decoder.(*Decoder).SymbolsInFile(0xc000797810, 0xc00052c066, 0x6, 0xc0005a8120, 0xc000797810, 0x0, 0x0, 0xc0000235f0)
	github.com/hashicorp/hcl-lang@v0.0.0-20210311200725-da0537032422/decoder/symbols.go:29 +0xf9
github.com/hashicorp/terraform-ls/internal/langserver/handlers.(*logHandler).TextDocumentSymbol(0xc0004b0008, 0x18677e0, 0xc0005b2150, 0xc00027e070, 0x6c, 0x0, 0x0, 0x02021/03/26 14:00:07 server.go:581: Received 1 new requests
, 0x0, 0x18677e0, ...)
	github.com/hashicorp/terraform-ls/internal/langserver/handlers/symbols.go:45 +0x2fc
reflect.Value.call(0x1527980, 0xc000516090, 0x13, 0x15b3186, 0x4, 0xc0005b2300, 0x2, 0x2, 0xc0005b2300, 0x199, ...)
	reflect/value.go:476 +0x8e7
reflect.Value.Call(0x1527980, 0xc000516090, 0x13, 0xc0005b2300, 0x2, 0x2, 0x2, 0xc0005b2300, 0x1)
	reflect/value.go:337 +0xb9
github.com/creachadair/jrpc2/handler.newHandler.func8(0x18677e0, 0xc0005b2150, 0xc0001b2040, 0x0, 0x0, 0x10, 0xc000516090)
	github.com/creachadair/jrpc2@v0.12.0/handler/handler.go:232 +0x1f4
github.com/creachadair/jrpc2/handler.Func.Handle(...)
	github.com/creachadair/jrpc2@v0.12.0/handler/handler.go:23
github.com/hashicorp/terraform-ls/internal/langserver/handlers.handle(0x18677e0, 0xc0005b2150, 0xc0001b2040, 0x1527980, 0xc000516090, 0xc0004ae0a0, 0x18677e0, 0xc0005b2150, 0x1554c60)
	github.com/hashicorp/terraform-ls/internal/langserver/handlers/service.go:393 +0x94
github.com/hashicorp/terraform-ls/internal/langserver/handlers.(*service).Assigner.func6(0x18677e0, 0xc0005b2150, 0xc0001b2040, 0x0, 0x0, 0x0, 0x0)
	github.com/hashicorp/terraform-ls/internal/langserver/handlers/service.go:204 +0x22b
reflect.Value.call(0x153e400, 0xc00049a300, 0x13, 0x15b3186, 0x4, 0xc0005b20c0, 0x2, 0x2, 0xc0005b20c0, 0x0, ...)
	reflect/value.go:476 +0x8e7
reflect.Value.Call(0x153e400, 0xc00049a300, 0x13, 0xc0005b20c0, 0x2, 0x2, 0x2, 0xc0005b20c0, 0x1)
	reflect/value.go:337 +0xb9
github.com/creachadair/jrpc2/handler.newHandler.func8(0x18677e0, 0xc0005b2090, 0xc0001b2040, 0x150c400, 0xc000516080, 0x1526e40, 0xc00000c048)
	github.com/creachadair/jrpc2@v0.12.0/handler/handler.go:232 +0x1f4
github.com/creachadair/jrpc2/handler.Func.Handle(0xc0004ba380, 0x18677e0, 0xc0005b2090, 0xc0001b2040, 0x0, 0x0, 0x18677e0, 0xc0005b2090)
	github.com/creachadair/jrpc2@v0.12.0/handler/handler.go:23 +0x44
github.com/creachadair/jrpc2.(*Server).invoke(0xc0004c6000, 0x1867738, 0xc0001b2140, 0x185ec00, 0xc0004ba380, 0xc0001b2040, 0x0, 0x0, 0x0, 0x0, ...)
	github.com/creachadair/jrpc2@v0.12.0/server.go:343 +0x1ab
github.com/creachadair/jrpc2.(*Server).dispatch.func1.1()
	github.com/creachadair/jrpc2@v0.12.0/server.go:225 +0xb7
github.com/creachadair/jrpc2.(*Server).dispatch.func1(0x0, 0x106e321)
	github.com/creachadair/jrpc2@v0.12.0/server.go:230 +0x16a
github.com/creachadair/jrpc2.(*Server).serve.func1(0xc0004c6000, 0xc000798000)
	github.com/creachadair/jrpc2@v0.12.0/server.go:151 +0x51
created by github.com/creachadair/jrpc2.(*Server).serve
	github.com/creachadair/jrpc2@v0.12.0/server.go:149 +0x71
[Error - 2:00:07 PM] Connection to server got closed. Server will not be restarted.
[Error - 2:00:07 PM] Request textDocument/documentSymbol failed.
Error: Connection got disposed.
	at Object.dispose (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/connection.js:1044:27)
	at Object.dispose (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-languageclient/lib/common/client.js:73:35)
	at LanguageClient.handleConnectionClosed (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-languageclient/lib/common/client.js:2352:42)
	at LanguageClient.handleConnectionClosed (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-languageclient/lib/node/main.js:155:15)
	at closeHandler (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-languageclient/lib/common/client.js:2339:18)
	at CallbackList.invoke (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/events.js:55:39)
	at Emitter.fire (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/events.js:117:36)
	at closeHandler (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/connection.js:256:26)
	at CallbackList.invoke (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/events.js:55:39)
	at Emitter.fire (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/events.js:117:36)
	at StreamMessageReader.fireClose (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/messageReader.js:40:27)
	at Socket.<anonymous> (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/messageReader.js:125:42)
	at Socket.emit (events.js:327:22)
	at Socket.EventEmitter.emit (domain.js:483:12)
	at Pipe.<anonymous> (net.js:674:12)
[Error - 2:00:07 PM] Request textDocument/documentLink failed.
Error: Connection got disposed.
	at Object.dispose (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/connection.js:1044:27)
	at Object.dispose (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-languageclient/lib/common/client.js:73:35)
	at LanguageClient.handleConnectionClosed (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-languageclient/lib/common/client.js:2352:42)
	at LanguageClient.handleConnectionClosed (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-languageclient/lib/node/main.js:155:15)
	at closeHandler (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-languageclient/lib/common/client.js:2339:18)
	at CallbackList.invoke (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/events.js:55:39)
	at Emitter.fire (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/events.js:117:36)
	at closeHandler (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/connection.js:256:26)
	at CallbackList.invoke (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/events.js:55:39)
	at Emitter.fire (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/events.js:117:36)
	at StreamMessageReader.fireClose (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/messageReader.js:40:27)
	at Socket.<anonymous> (/Users/REDACTED/.vscode/extensions/hashicorp.terraform-2.9.1/node_modules/vscode-jsonrpc/lib/common/messageReader.js:125:42)
	at Socket.emit (events.js:327:22)
	at Socket.EventEmitter.emit (domain.js:483:12)
	at Pipe.<anonymous> (net.js:674:12)
@radeksimko radeksimko transferred this issue from hashicorp/vscode-terraform Mar 26, 2021
@radeksimko radeksimko added the bug Something isn't working label Mar 26, 2021
@radeksimko
Copy link
Member

Thank you for the bug report and for attaching the relevant log. I think I have a rough idea of what the problem is and how to fix it - will update you when I have a fix or if I need more details.

@radeksimko
Copy link
Member

radeksimko commented Mar 26, 2021

I believe that I have a bug fix, but I'm still struggling to come up with a repro case. Would you mind sharing a snippet of code from your configuration to help build one?

There is likely an object or a map somewhere with interpolated key(s), such as:

foo = {
  "${in.ter}-polated" = "bar"
}

Unfortunately in all of my attempts keys with interpolation always come back as "unknown" type, so they're already being ignored due to not being string and not hitting the suspected bug/crash. I'd be therefore curious what kind of expressions (references, function calls, ...) you have in the key there.

@courteouselk
Copy link
Author

Yes, I have the code like that. I have added it (together with other things), and started to observe the crashes.

Here is my snippet:

variable "env" {
  type        = map(string)
}

locals {
  dns_zones = {
    "${var.env.cluster_id}.${var.env.dns_zone_domain}" = replace("${var.env.cluster_id}.${var.env.dns_zone_domain}", ".", "-")
    "${var.env.dns_zone_domain}"                       = "main"
  }
}

@radeksimko
Copy link
Member

Thank you, that helped. 🙏🏻 It's this particular expression:

"${var.env.cluster_id}.${var.env.dns_zone_domain}"

Adding that to my test case in hashicorp/hcl-lang#29 now...

@courteouselk
Copy link
Author

Awesome. Thanks for the lightning fast fix!

@ghost
Copy link

ghost commented May 8, 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 context necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators May 8, 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