Skip to content

fix: return MethodNotFound error for unrecognized LSP requests#4044

Open
hellozzm wants to merge 1 commit intoShopify:mainfrom
hellozzm:fix/method-not-found-response
Open

fix: return MethodNotFound error for unrecognized LSP requests#4044
hellozzm wants to merge 1 commit intoShopify:mainfrom
hellozzm:fix/method-not-found-response

Conversation

@hellozzm
Copy link
Copy Markdown

@hellozzm hellozzm commented Apr 3, 2026

Summary

The process_message case statement in lib/ruby_lsp/server.rb had no else clause, so unrecognized LSP methods (e.g. textDocument/prepareCallHierarchy) were silently dropped without sending a response. Per the LSP spec, servers must respond to any request bearing an id — for unsupported methods, that is error code -32601 (MethodNotFound).

Fixes #3981

Changes

  • Added an else branch to the case message[:method] statement in process_message
  • When a request has an id (i.e. expects a response) but the method is unrecognized, returns Error.new(id:, code: METHOD_NOT_FOUND, message: "Method not found: #{method}")
  • Notifications without an id are still silently ignored (correct per spec)

Testing

  • Verified the else clause correctly catches any unrecognized method string
  • Requests with message[:id] receive a proper error response with code -32601
  • Notifications (no id) continue to be silently dropped as expected
  • Existing behavior for all recognized methods is unchanged

When receiving an unsupported LSP method, the server now returns a
proper MethodNotFound (-32601) error response instead of silently
dropping the request. This prevents well-behaved clients from hanging
indefinitely waiting for a response.
@hellozzm hellozzm requested a review from a team as a code owner April 3, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unrecognized LSP requests are silently dropped instead of returning MethodNotFound (-32601)

1 participant