Skip to content
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

Error is raised when calling codeAction in NeoVim #3276

Open
datanoise opened this issue Mar 7, 2025 · 4 comments
Open

Error is raised when calling codeAction in NeoVim #3276

datanoise opened this issue Mar 7, 2025 · 4 comments
Labels
bug Something isn't working help-wanted Extra attention is needed non-vscode

Comments

@datanoise
Copy link

datanoise commented Mar 7, 2025

Description

I initially reported this error it to NeoVim.

Please check neovim/neovim#32757

Essentially, NeoVim added an additional call codeAction/resolve after calling textDocument/codeAction.

Resolve call fails with:

 .rbenv/versions/3.4.2/lib/ruby/3.4.0/uri/common.rb:871:in 'Kernel#URI': bad argument (expected URI object or URI string) (ArgumentError)
  from .rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.23.11/lib/ruby_lsp/server.rb:855:in 'RubyLsp::Server#code_action_resolve'
  from .rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.23.11/lib/ruby_lsp/server.rb:59:in 'RubyLsp::Server#process_message'
  from .rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.23.11/lib/ruby_lsp/base_server.rb:163:in 'block in RubyLsp::BaseServer#new_worker'
@datanoise datanoise added bug Something isn't working help-wanted Extra attention is needed non-vscode labels Mar 7, 2025
@vinistock
Copy link
Member

Thanks for the report. The backtrace is helpful, but do you also have the error message?

@andyw8
Copy link
Contributor

andyw8 commented Mar 7, 2025

@vinistock it's here: neovim/neovim#32757 (comment)

@datanoise
Copy link
Author

it looks like NeoVim team has fixed the issue by ignoring the error. I don't know if you want to look at the message they send:

{jsonrpc: "2.0", params: {isPreferred: true, edit: {documentChanges: [{textDocument: {uri: "file:///test_file.rb"}, edits: [{range: {end: {character: 0, line: 0}, start:{character: 0, line: 0}}, _index: 1, newText: "# frozen_string_literal: true\n"}]}]}, kind: "quickfix", title: "Autocorrect Style/FrozenStringLiteralComment"}, method: "codeAction/resolve", id: 6}

Currently code_action_resolve method fails because it tries to unconditionally parse URI from the missing key params.data.uri.

@vinistock
Copy link
Member

Currently code_action_resolve method fails because it tries to unconditionally parse URI from the missing key params.data.uri.

My understanding from the spec is that only code actions that do not include the edit attribute are eagerly resolved and all others should be resolved lazily.

We include the data.uri attribute for all code actions we want lazy resolution, which are the refactor related actions.

The only code actions we include the edit attribute for are quickfixes for RuboCop / Standard. If we're trying access a non existent data.uri, then I suspect the editor is trying to lazily resolve the quickfixes, which shouldn't be happening as they are eagerly resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help-wanted Extra attention is needed non-vscode
Projects
None yet
Development

No branches or pull requests

3 participants