Skip to content

x/tools/gopls: empty uri in publishDiagnostics from autogenerated.json #81025

Open

Description

@seankhliao

gopls version

gopls -v version
Build info

golang.org/x/tools/gopls (devel)
golang.org/x/tools/gopls@(devel)
github.com/BurntSushi/toml@v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
github.com/fatih/camelcase@v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=
github.com/fatih/gomodifytags@v1.17.1-0.20250423142747-f3939df9aa3c h1:dDSgAjoOMp8da3egfz0t2S+t8RGOpEmEXZubcGuc0Bg=
github.com/fatih/structtag@v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
github.com/fsnotify/fsnotify@v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/google/jsonschema-go@v0.4.3 h1:/DBOLZTfDow7pe2GmaJNhltueGTtDKICi8V8p+DQPd0=
github.com/modelcontextprotocol/go-sdk@v1.6.1 h1:0zOSupjKUxPKSocPT1Wtago+mUHU2/uZ4xSOY0FGReU=
github.com/segmentio/asm@v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0=
github.com/segmentio/encoding@v0.5.4 h1:OW1VRern8Nw6ITAtwSZ7Idrl3MXCFwXHPgqESYfvNt0=
github.com/yosida95/uritemplate/v3@v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
golang.org/x/exp/typeparams@v0.0.0-20260812173653-3d80eb74bc5b h1:F5AefKrjGj4r4Ht9ov1buP2PTyVb65dyf4bmdVKleV0=
golang.org/x/mod@v0.39.0 h1:UF5zwQdCRRUpHfyPwr7d4UrGiVeldIsogtzWVnczL74=
golang.org/x/oauth2@v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
golang.org/x/sync@v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
golang.org/x/sys@v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/telemetry@v0.0.0-20260811182544-a038080d80e5 h1:ZUSxONxc981v7AW7QUg+I9WwZzSTTJ019ENBYr5pV/Q=
golang.org/x/text@v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
golang.org/x/tools@v0.48.0 => ..
golang.org/x/vuln@v1.6.0 h1:FeMO9Rm/HwyduOztbvKcOw+zvDEPr4I4aQNSfevFcKY=
honnef.co/go/tools@v0.8.0-rc.1 h1:wqMm2kjcEXMOr+6yau+pdKqJKe6l2N1aKPkpini+Kzk=
mvdan.cc/gofumpt@v0.10.0 h1:yGGpRS2pBN2OQIi7b21IXknJna7faPkFaVfHLrN6Euo=
mvdan.cc/xurls/v2@v2.6.0 h1:3NTZpeTxYVWNSokW3MKeyVkz/j7uYXYiMtXRUfmjbgI=
go: go1.28-devel_7237c87c8c 2026-08-21 18:56:19 -0700

go env

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='0'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v3'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN='/home/user/.data/go/bin'
GOCACHE='/home/user/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS='-trimpath "-ldflags=-s -w" -vet=all'
GOGCCFLAGS='-fPIC -m64 -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build107581354=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/user/sdk/go/src/go.mod'
GOMODCACHE='/home/user/.data/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPACKAGESDRIVER=''
GOPATH='/home/user/.data/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/user/sdk/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/home/user/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='path'
GOTOOLDIR='/home/user/sdk/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.28-devel_7237c87c8c 2026-08-21 18:56:19 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

toggle compiler opts in neovim

What did you see happen?

vim.schedule callback: /usr/share/nvim/runtime/lua/vim/uri.lua:104: URI must contain a scheme:
stack traceback:
        [C]: in function 'error'
        /usr/share/nvim/runtime/lua/vim/uri.lua:104: in function 'uri_to_fname'
        /usr/share/nvim/runtime/lua/vim/lsp/diagnostic.lua:238: in function 'handle_diagnostics'
        /usr/share/nvim/runtime/lua/vim/lsp/diagnostic.lua:266: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp/client.lua:1323: in function '_notification'
        /usr/share/nvim/runtime/lua/vim/lsp/client.lua:470: in function 'fn'
        [string "vim/_core/editor"]:273: in function <[string "vim/_core/editor"]:272>

What did you expect to see?

No warning

Editor and settings

No response

Logs

Following up on #80496 , with CL 806961 landed I can see compiler optimizations now, but toggling the options still has the warning.

With some printf debugging in gopls #80496 (comment)
I think it's publishing an empty diagnostic for <autogenerated>.json which neovim doesn't like log.Println("YYY debug", fn, fh.URI(), fh):

compileropt.go:87: YYY debug /tmp/gopls-291274.details3417649164/archive%2Ftar/%3Cautogenerated%3E.json  
compileropt.go:87: YYY debug /tmp/gopls-291274.details3417649164/archive%2Ftar/common.json file:///home/user/sdk/go/src/archive/tar/common.go /home/user/sdk/go/src/archive/tar/common.go

Activity

  1. added
    goplsIssues related to the Go language server, gopls.
    ToolsThis label describes issues relating to any tools in the x/tools repository.
    on Aug 22, 2026
  2. added this to the Unreleased milestone on Aug 22, 2026
  3. adonovan commented on Aug 24, 2026

    @adonovan
    Member

    Perhaps the fix is as simple as changing the continue in parseDetailsFile to a break, so that it actually skips the whole file in that case?

    	for dec := json.NewDecoder(bytes.NewReader(buf)); dec.More(); {
    		// The first element always contains metadata.
    		if i == 0 {
    			i++
    			m := new(metadata)
    			if err := dec.Decode(m); err != nil {
    				return "", nil, err
    			}
    			if !strings.HasSuffix(m.File, ".go") {
    				break // <autogenerated>                    <- here
    			}
    			uri = protocol.URIFromPath(m.File)
    			continue
    		}
    		...

    It would be nice to also check that we got a uri before returning success.

  4. gopherbot commented on Sep 3, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/826984 mentions this issue: gopls/internal/golang: skip autogenerated compiler details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions