Skip to content

Command "Go: Add Tags to Struct Fields" fails with "unsupported modify tags operation" since gopls v0.23.0 #4070

Description

@zxysilent

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.26.5 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.23.0 ← the version where the bug occurs
      (I have since downgraded to v0.22.0 as a workaround, where the commands work)
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.128.1 (VS Code Server, commit 5264f2156cbcd7aea5fd004d29eaa10209155d66)
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.56.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • (omitted; let me know if you need it and I'll paste the output)

Share the Go related settings you have added/edited

None — all default settings. No go. / gopls prefixed settings were customized.

Describe the bug

The command-palette commands "Go: Add Tags to Struct Fields" and "Go: Remove Tags From Struct Fields" fail with unsupported modify tags operation (the operation value is empty) when running gopls v0.23.0 with vscode-go 0.56.0.

Every invocation logs this in the "gopls (server)" output channel:

[Error - ...] Request command/resolve failed.
Message: unsupported modify tags operation:
Code: 0

No tags are added/removed. The same commands worked fine with gopls v0.22.0.

Root cause analysis

I traced this through the source of both projects:

  1. gopls v0.23.0 changed the interactiveResolveProvider capability format (breaking change, gopls/internal/server/general.go):

    • v0.22.0: "interactiveResolveProvider": []string{"command"} (array)
    • v0.23.0: "interactiveResolveProvider": {kinds: ["command"]} (object)
  2. vscode-go 0.56.0's InteractiveFormsFeature middleware (extension/src/language/form.ts) activates when Array.isArray(option.kinds) && option.kinds.includes('command'). With v0.23.0 this now matches, so every workspace/executeCommand is first routed through a command/resolve request.

  3. The command-palette path still sends the legacy argument format (extension/src/goModifytags.ts): {URI, range, add, addOptions, transform, valueFormat} — i.e. no Modification field. (The code-action path from gopls sends Modification: "add"/"remove" and works fine.)

  4. gopls's resolveModifyTags (gopls/internal/golang/resolve.go) switches on a0.Modification and only handles "add" / "remove", falling through to:

    default:
        return fmt.Errorf("unsupported modify tags operation: %s", a0.Modification)

Since the legacy args have no Modification, the error surfaces with an empty operation.

Steps to reproduce the behavior:

  1. Open any .go file and select/place cursor on a struct (e.g. type Foo struct { A string }).
  2. Run command palette (Ctrl+Shift+P) → "Go: Add Tags to Struct Fields" (or "Go: Remove Tags From Struct Fields").
  3. Observe the "gopls (server)" output channel:
    Request command/resolve failed. Message: unsupported modify tags operation
  4. No changes are applied to the struct.

Expected behavior

Tags are added/removed as before (or the new interactive dialog is shown), without errors.

Workarounds

  • Use the lightbulb code action "Add struct tags" instead of the command palette — this path sends the new Modification-style args and works correctly.
  • Downgrade gopls to v0.22.0 (go install golang.org/x/tools/gopls@v0.22.0) — the commands work again.

Screenshots or recordings

N/A — the error is fully reproduced in the gopls output channel text above.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions