Skip to content

x/tools/gopls: CodeAction: unexpected JSON unmarshalling error in BundledLazyFixes (via telemetry) #68819

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

Closed
adonovan opened this issue Aug 9, 2024 · 3 comments
Assignees
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. gopls/telemetry-wins gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Aug 9, 2024

This stack pA-Ukg was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.BundledLazyFixes:+5
golang.org/x/tools/gopls/internal/server.(*server).codeActionsMatchingDiagnostics:+4
golang.org/x/tools/gopls/internal/server.(*server).CodeAction:+96
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+160
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/[email protected] go1.22.4 darwin/arm64 other (2)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan adonovan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. gopls/telemetry-wins labels Aug 9, 2024
@gopherbot gopherbot added this to the Unreleased milestone Aug 9, 2024
@adonovan
Copy link
Member Author

Given the analysis in #64503 (comment), and the fact the hypothesis (3) is no longer possible due to https://go.dev/cl/549575, hypothesis (1) seems likely: "a curious user or misbehaving client is sending home-made or invalid BundledFixes messages, or modifying the value before returning it to the server". The fact that the the LSP client string is "other" adds a small amount of evidentiary weight.

We should probably downgrade the bug.Report to silently discard the message on the grounds that the client has meddled with it, or, better, report an ordinary error to be handled by the caller.

@adonovan adonovan removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 12, 2024
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.17.0 Aug 29, 2024
@findleyr findleyr self-assigned this Nov 15, 2024
@findleyr findleyr added the FixPending Issues that have a fix which has not yet been reviewed or submitted. label Nov 15, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/628237 mentions this issue: gopls/internal/cache: failure to extract diagnostic fixes is an error

dennypenta pushed a commit to dennypenta/tools that referenced this issue Dec 3, 2024
Although the LSP specifies that diagnostic data should be transmitted
unmodified to codeAction requests, we can't control whether clients
abide by this rule. Therefore, a failure to extract fixes should be
treated as a user-facing error, not a bug.

Fixes golang/go#68819

Change-Id: I57e629cf381ee1112d98d22e728449995679b05f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/628237
Reviewed-by: Alan Donovan <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. gopls/telemetry-wins gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants