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

Fix ruby-lsp-check raising when server message itself is an error #2659

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

Earlopain
Copy link
Contributor

@Earlopain Earlopain commented Oct 3, 2024

Motivation

Stacktrace

$ bundle exec ruby-lsp-check
/home/earlopain/.rbenv/versions/3.3.5/lib/ruby/3.3.0/json/common.rb:3: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add ostruct to your Gemfile or gemspec to silence this warning.
Verifying that all automatic LSP requests execute successfully. This may take a while...
Completed 136/136
Verifying that indexing executes successfully. This may take a while...
Indexed 2015/2015
/home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.19.0/exe/ruby-lsp-check:66:in `block in <top (required)>': undefined method `message' for an instance of String (NoMethodError)

  #{errors.map { |file, error| "#{file}: #{error.message}" }.join("\n")}
                                                ^^^^^^^^
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.19.0/exe/ruby-lsp-check:66:in `each'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.19.0/exe/ruby-lsp-check:66:in `map'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.19.0/exe/ruby-lsp-check:66:in `<top (required)>'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/bin/ruby-lsp-check:25:in `load'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/bin/ruby-lsp-check:25:in `<top (required)>'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli/exec.rb:58:in `load'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli/exec.rb:58:in `kernel_load'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli/exec.rb:23:in `run'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:455:in `exec'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:35:in `dispatch'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:29:in `start'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/exe/bundle:28:in `block in <top (required)>'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/exe/bundle:20:in `<top (required)>'
        from /home/earlopain/.rbenv/versions/3.3.5/bin/bundle:25:in `load'
        from /home/earlopain/.rbenv/versions/3.3.5/bin/bundle:25:in `<main>'

Implementation

The hash must beString => StandardError since at the end it calls message on it already.

Automated Tests

Seems hard since this should never fail anyways

Manual Tests

Not sure, still looking into the failure myself. But at least the troubleshooting works with this (:. I guess you can make the server raise one manually if you want to check it out.

The hash must be`String => StandardError` since at the end it calls `message` on it already.

```rb
$ bundle exec ruby-lsp-check
/home/earlopain/.rbenv/versions/3.3.5/lib/ruby/3.3.0/json/common.rb:3: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add ostruct to your Gemfile or gemspec to silence this warning.
Verifying that all automatic LSP requests execute successfully. This may take a while...
Completed 136/136
Verifying that indexing executes successfully. This may take a while...
Indexed 2015/2015
/home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.19.0/exe/ruby-lsp-check:66:in `block in <top (required)>': undefined method `message' for an instance of String (NoMethodError)

  #{errors.map { |file, error| "#{file}: #{error.message}" }.join("\n")}
                                                ^^^^^^^^
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.19.0/exe/ruby-lsp-check:66:in `each'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.19.0/exe/ruby-lsp-check:66:in `map'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.19.0/exe/ruby-lsp-check:66:in `<top (required)>'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/bin/ruby-lsp-check:25:in `load'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/bin/ruby-lsp-check:25:in `<top (required)>'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli/exec.rb:58:in `load'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli/exec.rb:58:in `kernel_load'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli/exec.rb:23:in `run'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:455:in `exec'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:35:in `dispatch'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:29:in `start'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/exe/bundle:28:in `block in <top (required)>'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/site_ruby/3.3.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        from /home/earlopain/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.20/exe/bundle:20:in `<top (required)>'
        from /home/earlopain/.rbenv/versions/3.3.5/bin/bundle:25:in `load'
        from /home/earlopain/.rbenv/versions/3.3.5/bin/bundle:25:in `<main>'
```
@Earlopain Earlopain requested a review from a team as a code owner October 3, 2024 10:52
@Earlopain Earlopain requested review from st0012 and vinistock October 3, 2024 10:52
Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@st0012 st0012 added the bugfix This PR will fix an existing bug label Oct 3, 2024
@st0012 st0012 enabled auto-merge (squash) October 3, 2024 10:58
@st0012 st0012 added the server This pull request should be included in the server gem's release notes label Oct 3, 2024
@st0012 st0012 merged commit a7373cc into Shopify:main Oct 3, 2024
19 of 20 checks passed
@Earlopain Earlopain deleted the check-command-error branch October 3, 2024 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants