{"record":{"id":"31da62eddcd73c27","repo":"astral-sh/ruff","slug":"methodnotfound","errorCode":"MethodNotFound","errorMessage":"Unknown request: {method}","messagePattern":"Unknown request: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/ruff_server/src/server/api.rs","lineNumber":74,"sourceCode":"        }\n        request::DocumentDiagnostic::METHOD => {\n            background_request_task::<request::DocumentDiagnostic>(req, BackgroundSchedule::Worker)\n        }\n        request::ExecuteCommand::METHOD => sync_request_task::<request::ExecuteCommand>(req),\n        request::Format::METHOD => {\n            background_request_task::<request::Format>(req, BackgroundSchedule::Fmt)\n        }\n        request::FormatRange::METHOD => {\n            background_request_task::<request::FormatRange>(req, BackgroundSchedule::Fmt)\n        }\n        request::Hover::METHOD => {\n            background_request_task::<request::Hover>(req, BackgroundSchedule::Worker)\n        }\n        lsp_types::ShutdownRequest::METHOD => sync_request_task::<requests::ShutdownHandler>(req),\n        method => {\n            tracing::warn!(\"Received request {method} which does not have a handler\");\n            let result: Result<()> = Err(Error::new(\n                anyhow!(\"Unknown request: {method}\"),\n                server::ErrorCode::MethodNotFound,\n            ));\n            return Task::immediate(id, result);\n        }\n    }\n    .unwrap_or_else(|err| {\n        tracing::error!(\"Encountered error when routing request with ID {id}: {err}\");\n\n        Task::sync(move |_session, client| {\n            client.show_error_message(\n                \"Ruff failed to handle a request from the editor. Check the logs for more details.\",\n            );\n            respond_silent_error(\n                id,\n                client,\n                lsp_server::ResponseError {\n                    code: err.code as i32,\n                    message: err.to_string(),","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_server/src/server/api.rs#L56-L92","documentation":"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.","triggerScenarios":"Client sends a request such as `textDocument/codeLens`, `textDocument/documentSymbol`, or a newer LSP method that Ruff's `request` dispatcher does not match.","commonSituations":"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.","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"],"exampleFix":"// before\nsendRequest('textDocument/documentSymbol', params)\n// after\nif (serverCapabilities.documentSymbolProvider) {\n  sendRequest('textDocument/documentSymbol', params);\n}","handlingStrategy":"try-catch","validationCode":"// Client: only send requests the server declared in initialize result\nfunction serverSupports(caps: any, key: string): boolean {\n  return Boolean(caps?.textDocument?.[key] ?? caps?.[key]);\n}\n// e.g. serverSupports(capabilities, 'hover') before textDocument/hover","typeGuard":null,"tryCatchPattern":"// TypeScript\ntry {\n  return await client.sendRequest('textDocument/hover', params);\n} catch (e) {\n  if (e.code === -32601 /* MethodNotFound */) return null;\n  throw e;\n}","preventionTips":["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"],"tags":["rust","lsp","server","method-not-found"],"backgroundTag":"lsp-method-not-found","analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}