juliosueiras / terraform-lsp

Language Server Protocol for Terraform
MIT License
579 stars 37 forks source link

panic at helper.ParseVariables #89

Open kamil-rogon-dragon opened 4 years ago

kamil-rogon-dragon commented 4 years ago

Panic while trying to get completion on available variable names.

resource "postgresql_database" "this" {
  name = var.name
  owner = var.
}

variable "main_username" {
  default = "postgres"
  type    = string
}

variable "name" {
  default = "name-1"
}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x154405e]

goroutine 216 [running]:
github.com/zclconf/go-cty/cty.Type.FriendlyName(...)
    /home/runner/work/terraform-lsp/terraform-lsp/vendor/github.com/zclconf/go-cty/cty/type.go:44
github.com/juliosueiras/terraform-lsp/helper.ParseVariables(0xc0007c83c0, 0x0, 0x0, 0xc000488570, 0xc0003e7d40, 0x1, 0x1, 0xc000640800, 0x2e00108, 0x0)
    /home/runner/work/terraform-lsp/terraform-lsp/helper/file.go:97 +0x10e
github.com/juliosueiras/terraform-lsp/tfstructs.GetVarAttributeCompletion(0xc0007c83c0, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc00051cb80, 0x21bea60, 0xc00044b130, 0xc000811737, ...)
    /home/runner/work/terraform-lsp/terraform-lsp/tfstructs/vars.go:67 +0x3331
github.com/juliosueiras/terraform-lsp/langserver.TextDocumentComplete(0x21be420, 0xc00080ff50, 0xc0008116c0, 0x6e, 0x2, 0xe, 0x2, 0x299442e, 0x1, 0x0, ...)
    /home/runner/work/terraform-lsp/terraform-lsp/langserver/complete.go:323 +0x18fe
reflect.Value.call(0x1d1d2a0, 0x1f049e0, 0x13, 0x1eafb56, 0x4, 0xc00080ff80, 0x2, 0x2, 0x18, 0xc000912280, ...)
    /opt/hostedtoolcache/go/1.14.4/x64/src/reflect/value.go:460 +0x8ab
reflect.Value.Call(0x1d1d2a0, 0x1f049e0, 0x13, 0xc00080ff80, 0x2, 0x2, 0x2, 0xc00080ff80, 0x1)
    /opt/hostedtoolcache/go/1.14.4/x64/src/reflect/value.go:321 +0xb4
github.com/creachadair/jrpc2/handler.newHandler.func7(0x21be420, 0xc00080ff50, 0xc00011c780, 0x1e11080, 0xc00080ff50, 0x1d345a0, 0x2a4dcd8)
    /home/runner/work/terraform-lsp/terraform-lsp/vendor/github.com/creachadair/jrpc2/handler/handler.go:222 +0x20a
github.com/creachadair/jrpc2/handler.Func.Handle(0xc000818340, 0x21be420, 0xc00080ff50, 0xc00011c780, 0x0, 0x0, 0x21be420, 0xc00080ff50)
    /home/runner/work/terraform-lsp/terraform-lsp/vendor/github.com/creachadair/jrpc2/handler/handler.go:23 +0x44
github.com/creachadair/jrpc2.(*Server).invoke(0xc0000e0240, 0x21be360, 0xc00011c7c0, 0x21a1a60, 0xc000818340, 0xc00011c780, 0x0, 0x0, 0x0, 0x0, ...)
    /home/runner/work/terraform-lsp/terraform-lsp/vendor/github.com/creachadair/jrpc2/server.go:288 +0x168
github.com/creachadair/jrpc2.(*Server).dispatch.func1(0xc000479aa0, 0xc0000e0240, 0xc0004e20c0)
    /home/runner/work/terraform-lsp/terraform-lsp/vendor/github.com/creachadair/jrpc2/server.go:185 +0x91
created by github.com/creachadair/jrpc2.(*Server).dispatch
    /home/runner/work/terraform-lsp/terraform-lsp/vendor/github.com/creachadair/jrpc2/server.go:183 +0x137
[Info  - 10:32:05 PM] Connection to server got closed. Server will restart.
[Error - 10:32:05 PM] Request textDocument/completion failed.
Error: Connection got disposed.
    at Object.dispose (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-jsonrpc/lib/main.js:876:25)
    at Object.dispose (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-languageclient/lib/client.js:71:35)
    at LanguageClient.handleConnectionClosed (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-languageclient/lib/client.js:2153:42)
    at LanguageClient.handleConnectionClosed (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-languageclient/lib/main.js:151:15)
    at closeHandler (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-languageclient/lib/client.js:2140:18)
    at CallbackList.invoke (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-jsonrpc/lib/events.js:120:36)
    at closeHandler (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-jsonrpc/lib/main.js:226:26)
    at CallbackList.invoke (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-jsonrpc/lib/events.js:120:36)
    at StreamMessageReader.fireClose (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
    at Socket.<anonymous> (/Users/dummy/.vscode/extensions/mauve.terraform-1.4.0/node_modules/vscode-jsonrpc/lib/messageReader.js:151:46)
    at Socket.emit (events.js:228:7)
    at Pipe.<anonymous> (net.js:664:12)