astral-sh/ruff · warning
MethodNotFound
MethodNotFound
Error message
Unknown request: {method} What it means
The server's request dispatcher matches incoming LSP request methods to handlers. Any request whose method has no registered handler (e.g. an LSP feature Ruff doesn't implement) is logged as a warning and returned to the client as a MethodNotFound (-32601) error carrying this message.
Solutions
- Check server capabilities in the initialize response and only send supported requests
- Update the Ruff LSP server if the missing method is a feature it should support
- Fix client routing so requests intended for another language server go there
- This is usually benign (declined feature); silence the client-side error or handle MethodNotFound gracefully
Example fix
// before
sendRequest('textDocument/documentSymbol', params)
// after
if (serverCapabilities.documentSymbolProvider) {
sendRequest('textDocument/documentSymbol', params);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Client: only send requests the server declared in initialize result
function serverSupports(caps: any, key: string): boolean {
return Boolean(caps?.textDocument?.[key] ?? caps?.[key]);
}
// e.g. serverSupports(capabilities, 'hover') before textDocument/hover Try / catch
// TypeScript
try {
return await client.sendRequest('textDocument/hover', params);
} catch (e) {
if (e.code === -32601 /* MethodNotFound */) return null;
throw e;
} Prevention
- Gate every request on the corresponding server capability from initialize
- Handle -32601 MethodNotFound as 'feature unavailable', not a fatal error
- Keep server and client LSP versions aligned
- Avoid sending experimental/vendor requests to Ruff
When it happens
Trigger: Client sends a request such as `textDocument/codeLens`, `textDocument/documentSymbol`, or a newer LSP method that Ruff's `request` dispatcher does not match.
Common situations: Editor assumes server capabilities not declared (or declares more itself); a plugin sends Ruff-specific requests to the wrong server; version mismatch where the client uses a newly added LSP method the server doesn't know.
Related errors
- Attempted to add edits for a document that was already…
- InternalError
- Invalid command
- JSON parsing failure
- -32603
AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05).
Data as JSON: /api/errors/31da62eddcd73c27.
Report an issue: GitHub.
Appendix: source
Thrown at crates/ruff_server/src/server/api.rs:74
}
request::DocumentDiagnostic::METHOD => {
background_request_task::<request::DocumentDiagnostic>(req, BackgroundSchedule::Worker)
}
request::ExecuteCommand::METHOD => sync_request_task::<request::ExecuteCommand>(req),
request::Format::METHOD => {
background_request_task::<request::Format>(req, BackgroundSchedule::Fmt)
}
request::FormatRange::METHOD => {
background_request_task::<request::FormatRange>(req, BackgroundSchedule::Fmt)
}
request::Hover::METHOD => {
background_request_task::<request::Hover>(req, BackgroundSchedule::Worker)
}
lsp_types::ShutdownRequest::METHOD => sync_request_task::<requests::ShutdownHandler>(req),
method => {
tracing::warn!("Received request {method} which does not have a handler");
let result: Result<()> = Err(Error::new(
anyhow!("Unknown request: {method}"),
server::ErrorCode::MethodNotFound,
));
return Task::immediate(id, result);
}
}
.unwrap_or_else(|err| {
tracing::error!("Encountered error when routing request with ID {id}: {err}");
Task::sync(move |_session, client| {
client.show_error_message(
"Ruff failed to handle a request from the editor. Check the logs for more details.",
);
respond_silent_error(
id,
client,
lsp_server::ResponseError {
code: err.code as i32,
message: err.to_string(),View on GitHub (pinned to 26f38c119c)