Skip to content

Return MethodNotFound (-32601) for unrecognized LSP requests#4040

Open
IgorFroehner wants to merge 1 commit intoShopify:mainfrom
IgorFroehner:fix-method-not-found-error
Open

Return MethodNotFound (-32601) for unrecognized LSP requests#4040
IgorFroehner wants to merge 1 commit intoShopify:mainfrom
IgorFroehner:fix-method-not-found-error

Conversation

@IgorFroehner
Copy link
Copy Markdown

@IgorFroehner IgorFroehner commented Mar 31, 2026

Motivation

Fixes #3981

The process_message case statement had no else clause, so requests for unsupported methods were silently dropped. This caused clients to hang indefinitely waiting for a response. The LSP spec requires servers to respond with error code -32601 for unsupported methods.

Implementation

Just answer with Method not found when the message method don't match any of the switch statement branches.

Automated Tests

I added one check to see if the message RubyLsp::Error was sent.

Manual Tests

Start the server via bundle exec ruby-lsp and send a request with an unsupported method (e.g. textDocument/nonExistentMethod). Verify the server responds with {"error": {"code": -32601, "message": "Method not found: textDocument/nonExistentMethod"}} instead of silently dropping the request.

The process_message case statement had no else clause, so requests for
unsupported methods were silently dropped. This caused clients to hang
indefinitely waiting for a response. The LSP spec requires servers to
respond with error code -32601 for unsupported methods.

Fixes Shopify#3981
@IgorFroehner IgorFroehner requested a review from a team as a code owner March 31, 2026 02:46
@IgorFroehner
Copy link
Copy Markdown
Author

I have signed the CLA!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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