-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Given a bake file that's being edited like so:
variable "CI" {
type = string
}
variable "foo" {
type = bool
default = C
}a panic happens when typing "I" (i.e., finishing the line to read default = CI == null):
2025/11/20 18:42:27 jsonrpc2 handler: notification "$/cancelRequest" handling error: jsonrpc2: code -32601 message: method not supported: $/cancelRequest
goroutine 52 [running]:
runtime/debug.Stack()
/opt/hostedtoolcache/go/1.25.3/x64/src/runtime/debug/stack.go:26 +0x5e
runtime/debug.PrintStack()
/opt/hostedtoolcache/go/1.25.3/x64/src/runtime/debug/stack.go:18 +0x13
github.com/docker/docker-language-server/internal/pkg/server.(*Server).handleRecovered(0xc00030eb40, {0xc0005aa0f0, 0x16}, {0x1217580, 0x1f176c0})
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/server/server.go:207 +0x68
github.com/docker/docker-language-server/internal/pkg/server.NewServer.func1({0xc0005aa0f0?, 0xc0005f5f30?}, {0x1217580?, 0x1f176c0?})
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/server/server.go:135 +0x35
github.com/docker/docker-language-server/internal/tliron/glsp/protocol.(*Handler).Handle.func1()
/home/runner/work/docker-language-server/docker-language-server/internal/tliron/glsp/protocol/handler.go:100 +0x65
panic({0x1217580?, 0x1f176c0?})
/opt/hostedtoolcache/go/1.25.3/x64/src/runtime/panic.go:783 +0x132
github.com/zclconf/go-cty/cty.Type.FriendlyName(...)
/home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.17.0/cty/type.go:47
github.com/zclconf/go-cty/cty/convert.MismatchMessage({{0x0?, 0x0?}}, {{0x15e4590?, 0x15ccb98?}})
/home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.17.0/cty/convert/mismatch_msg.go:57 +0x2de
github.com/zclconf/go-cty/cty/convert.Convert({{{0x0?, 0x0?}}, {0x0?, 0x0?}}, {{0x15e4590?, 0x15ccb98?}})
/home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.17.0/cty/convert/public.go:49 +0x168
github.com/docker/buildx/bake/hclparser.(*parser).resolveValue(0xc0004bd500, 0xc00013ca68, {0xc00027f93c, 0x4})
/home/runner/go/pkg/mod/github.com/docker/buildx@v0.29.0/bake/hclparser/hclparser.go:326 +0x1152
github.com/docker/buildx/bake/hclparser.Parse({0x15e46e8, 0xc000c03bd8}, {0x1470cc0?, 0x0?, 0x1470cb8?}, {0x131b5a0, 0xc000b8e390})
/home/runner/go/pkg/mod/github.com/docker/buildx@v0.29.0/bake/hclparser/hclparser.go:802 +0xda6
github.com/docker/buildx/bake.ParseFiles({0xc0005f76d0, 0x1, 0x11f?}, 0x0)
/home/runner/go/pkg/mod/github.com/docker/buildx@v0.29.0/bake/bake.go:380 +0xaaf
github.com/docker/buildx/bake.ReadTargets({0x1196840?, 0xc0005f7610?}, {0xc0005f76d0?, 0x2404?, 0xc0009f93e2?}, {0xc0004bc200, 0x5, 0xc000478420?}, {0x0, 0x0, ...}, ...)
/home/runner/go/pkg/mod/github.com/docker/buildx@v0.29.0/bake/bake.go:199 +0x46
github.com/docker/docker-language-server/internal/pkg/document.(*bakeHCLDocument).extractBakeOutput(0xc0002e22a0)
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/bakeDocument.go:187 +0x367
github.com/docker/docker-language-server/internal/pkg/document.(*bakeHCLDocument).parse(0xc0002e22a0, 0xd1?)
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/bakeDocument.go:68 +0x1b6
github.com/docker/docker-language-server/internal/pkg/document.(*document).Update(...)
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/document.go:84
github.com/docker/docker-language-server/internal/pkg/document.(*Manager).parse(0xc00079edb0, {0xc000a078d0?, 0xc000478060?}, {0xc000478060, 0x5d}, {0x13d965f, 0xa}, 0x8, {0xc0009f8000, 0x13e2, ...})
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/manager.go:248 +0x88
github.com/docker/docker-language-server/internal/pkg/document.(*Manager).write(0xc000a079b8?, {0x15e38a8?, 0xc0002e2000?}, {0xc000478060, 0x5d}, {0x13d965f?, 0xc000a07900?}, 0x1500?, {0xc0009f8000, 0x13e2, ...})
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/manager.go:180 +0x6d
github.com/docker/docker-language-server/internal/pkg/document.(*Manager).Overwrite(0xc00079edb0, {0x15e38a8, 0xc0002e2000}, {0xc000478060, 0x5d}, 0x8, {0xc0009f8000, 0x13e2, 0x1500})
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/manager.go:203 +0x1c5
github.com/docker/docker-language-server/internal/pkg/server.(*Server).TextDocumentDidChange(0xc00030eb40, 0xc000856280, 0xc0009d3d40)
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/server/text_document_sync.go:38 +0xd6
github.com/docker/docker-language-server/internal/tliron/glsp/protocol.(*Handler).Handle(0xc000316488, 0xc000856280)
/home/runner/work/docker-language-server/docker-language-server/internal/tliron/glsp/protocol/handler.go:336 +0x11c8
github.com/docker/docker-language-server/internal/tliron/glsp/server.(*Server).handle(0xc00013e240, {0x15e38a8, 0xc0002e2000}, 0xc00078f680, 0xc0008e86c0)
/home/runner/work/docker-language-server/docker-language-server/internal/tliron/glsp/server/handler.go:69 +0x267
github.com/sourcegraph/jsonrpc2.(*HandlerWithErrorConfigurer).Handle(0xc000787840, {0x15e38a8, 0xc0002e2000}, 0xc00078f680, 0xc0008e86c0)
/home/runner/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.2.0/handler_with_error.go:21 +0x57
github.com/docker/docker-language-server/internal/tliron/glsp/server.(*AsynchronousRequestHandler).Handle(0xc000787850?, {0x15e38a8?, 0xc0002e2000?}, 0xc00078f680?, 0xc000a1f560?)
/home/runner/work/docker-language-server/docker-language-server/internal/tliron/glsp/server/handler.go:29 +0x87
github.com/sourcegraph/jsonrpc2.(*Conn).readMessages(0xc00078f680, {0x15e38a8, 0xc0002e2000})
/home/runner/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.2.0/conn.go:205 +0x2e6
created by github.com/sourcegraph/jsonrpc2.NewConn in goroutine 1
/home/runner/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.2.0/conn.go:62 +0x1e6
2025/11/20 18:42:28 notifying bugsnag: runtime error: invalid memory address or nil pointer dereference
2025/11/20 18:42:28 jsonrpc2 handler: notification "textDocument/didChange" handling error: jsonrpc2: code -32803 message: Internal server error
goroutine 52 [running]:
runtime/debug.Stack()
/opt/hostedtoolcache/go/1.25.3/x64/src/runtime/debug/stack.go:26 +0x5e
runtime/debug.PrintStack()
/opt/hostedtoolcache/go/1.25.3/x64/src/runtime/debug/stack.go:18 +0x13
github.com/docker/docker-language-server/internal/pkg/server.(*Server).handleRecovered(0xc00030eb40, {0xc0006d08e0, 0x1e}, {0x1217580, 0x1f176c0})
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/server/server.go:207 +0x68
github.com/docker/docker-language-server/internal/pkg/server.NewServer.func1({0xc0006d08e0?, 0xc0005f5f58?}, {0x1217580?, 0x1f176c0?})
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/server/server.go:135 +0x35
github.com/docker/docker-language-server/internal/tliron/glsp/protocol.(*Handler).Handle.func1()
/home/runner/work/docker-language-server/docker-language-server/internal/tliron/glsp/protocol/handler.go:100 +0x65
panic({0x1217580?, 0x1f176c0?})
/opt/hostedtoolcache/go/1.25.3/x64/src/runtime/panic.go:783 +0x132
github.com/zclconf/go-cty/cty.Type.FriendlyName(...)
/home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.17.0/cty/type.go:47
github.com/zclconf/go-cty/cty/convert.MismatchMessage({{0x0?, 0x0?}}, {{0x15e4590?, 0x15ccb98?}})
/home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.17.0/cty/convert/mismatch_msg.go:57 +0x2de
github.com/zclconf/go-cty/cty/convert.Convert({{{0x0?, 0x0?}}, {0x0?, 0x0?}}, {{0x15e4590?, 0x15ccb98?}})
/home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.17.0/cty/convert/public.go:49 +0x168
github.com/docker/buildx/bake/hclparser.(*parser).resolveValue(0xc000063380, 0xc0006f0870, {0xc000013bcc, 0x4})
/home/runner/go/pkg/mod/github.com/docker/buildx@v0.29.0/bake/hclparser/hclparser.go:326 +0x1152
github.com/docker/buildx/bake/hclparser.Parse({0x15e46e8, 0xc000011e00}, {0x1470cc0?, 0x0?, 0x1470cb8?}, {0x131b5a0, 0xc00003e9c0})
/home/runner/go/pkg/mod/github.com/docker/buildx@v0.29.0/bake/hclparser/hclparser.go:802 +0xda6
github.com/docker/buildx/bake.ParseFiles({0xc0005f76f8, 0x1, 0x11f?}, 0x0)
/home/runner/go/pkg/mod/github.com/docker/buildx@v0.29.0/bake/bake.go:380 +0xaaf
github.com/docker/buildx/bake.ReadTargets({0x1196840?, 0xc0005f7638?}, {0xc0005f76f8?, 0x2404?, 0xc0009f93e2?}, {0xc000062080, 0x5, 0xc000478420?}, {0x0, 0x0, ...}, ...)
/home/runner/go/pkg/mod/github.com/docker/buildx@v0.29.0/bake/bake.go:199 +0x46
github.com/docker/docker-language-server/internal/pkg/document.(*bakeHCLDocument).extractBakeOutput(0xc0002a52d0)
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/bakeDocument.go:187 +0x367
github.com/docker/docker-language-server/internal/pkg/document.(*bakeHCLDocument).parse(0xc0002a52d0, 0x1?)
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/bakeDocument.go:68 +0x1b6
github.com/docker/docker-language-server/internal/pkg/document.NewBakeHCLDocument({0xc000478420, 0x5d}, 0x8, {0xc0009f8000, 0x13e2, 0x1500})
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/bakeDocument.go:46 +0x151
github.com/docker/docker-language-server/internal/pkg/document.(*bakeHCLDocument).copy(...)
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/bakeDocument.go:73
github.com/docker/docker-language-server/internal/pkg/document.(*document).Copy(...)
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/document.go:127
github.com/docker/docker-language-server/internal/pkg/document.(*Manager).tryReading.func1()
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/manager.go:128 +0x37
github.com/docker/docker-language-server/internal/pkg/document.(*Manager).tryReading(0xc00079edb0, {0x15e38a8, 0xc0002e2000}, {0xc000478180, 0x5d}, 0x1)
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/manager.go:147 +0x1e4
github.com/docker/docker-language-server/internal/pkg/document.(*Manager).Read(...)
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/document/manager.go:116
github.com/docker/docker-language-server/internal/pkg/server.(*Server).TextDocumentDocumentHighlight(0xc00030eb40, 0xc0004fc658?, 0xc00003e360)
/home/runner/work/docker-language-server/docker-language-server/internal/pkg/server/documentHighlight.go:13 +0x72
github.com/docker/docker-language-server/internal/tliron/glsp/protocol.(*Handler).Handle(0xc000316488, 0xc00001cd20)
/home/runner/work/docker-language-server/docker-language-server/internal/tliron/glsp/protocol/handler.go:478 +0x2cb9
github.com/docker/docker-language-server/internal/tliron/glsp/server.(*Server).handle(0xc00013e240, {0x15e38a8, 0xc0002e2000}, 0xc00078f680, 0xc0007e0960)
/home/runner/work/docker-language-server/docker-language-server/internal/tliron/glsp/server/handler.go:69 +0x267
github.com/sourcegraph/jsonrpc2.(*HandlerWithErrorConfigurer).Handle(0xc000787840, {0x15e38a8, 0xc0002e2000}, 0xc00078f680, 0xc0007e0960)
/home/runner/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.2.0/handler_with_error.go:21 +0x57
github.com/docker/docker-language-server/internal/tliron/glsp/server.(*AsynchronousRequestHandler).Handle(0xc000787850?, {0x15e38a8?, 0xc0002e2000?}, 0xc00078f680?, 0xc0007e0960?)
/home/runner/work/docker-language-server/docker-language-server/internal/tliron/glsp/server/handler.go:29 +0x87
github.com/sourcegraph/jsonrpc2.(*Conn).readMessages(0xc00078f680, {0x15e38a8, 0xc0002e2000})
/home/runner/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.2.0/conn.go:205 +0x2e6
created by github.com/sourcegraph/jsonrpc2.NewConn in goroutine 1
/home/runner/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.2.0/conn.go:62 +0x1e6
2025/11/20 18:42:28 notifying bugsnag: runtime error: invalid memory address or nil pointer dereference
The fix is to simply upgrade github.com/docker/buildx to at least v0.30.0.
I built it with v0.30.1 and manually confirmed it works. I would have created a PR, but.I wasn't sure if you'd want a test (even though it's not a code change), and it wasn't obvious where one would even belong (and couldn't spot any similar tests to use as a guide). I'm very new to this project and LSP in general, so played it safe by just reporting the issue.
The reason I know the upgrade fixes it is because I'm the one responsible for the underlying bug, which I then fixed in docker/buildx#3464. The workarounds from the original report docker/buildx#3463 will also stop the server from panicking.
I'd be happy to create a PR if you can point me to an example test to start from, or if you're good with just the dependency change.