{"record":{"id":"ed11b5958f4754e5","repo":"astral-sh/ruff","slug":"methodnotfound","errorCode":"MethodNotFound","errorMessage":"Unknown request: {method}","messagePattern":"Unknown request: (.+?)","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"crates/ty_server/src/server/api.rs","lineNumber":154,"sourceCode":"        ),\n        requests::CallHierarchyIncomingCallsRequestHandler::METHOD => {\n            background_request_task::<requests::CallHierarchyIncomingCallsRequestHandler>(\n                req,\n                BackgroundSchedule::Worker,\n            )\n        }\n        requests::CallHierarchyOutgoingCallsRequestHandler::METHOD => {\n            background_request_task::<requests::CallHierarchyOutgoingCallsRequestHandler>(\n                req,\n                BackgroundSchedule::Worker,\n            )\n        }\n        lsp_types::ShutdownRequest::METHOD => sync_request_task::<requests::ShutdownHandler>(req),\n\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            if matches!(err.code, ErrorCode::InternalError) {\n                client.show_error_message(format!(\n                    \"ty failed to handle a request from the editor. {}\",\n                    session.client_name().log_guidance()\n                ));\n            }\n\n            respond_silent_error(\n                id,","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/astral-sh/ruff/blob/672bb4edf04c84f8b0753346359daee4057158f2/crates/ty_server/src/server/api.rs#L136-L172","documentation":"The request router in api.rs matched the incoming method against no registered handler, so the server replies with LSP error code MethodNotFound and logs 'Received request {method} which does not have a handler'. This is a protocol-level 'feature not implemented' response, not a crash.","triggerScenarios":"The client sends a request method ty's server does not implement — e.g. codeLens, semanticTokens/full, or inlayHints when no handler exists — typically because the client ignores the server's advertised capabilities.","commonSituations":"Editor extensions enabling features the server never advertised, version skew between client plugin and ty server, custom/typo'd method strings, or clients assuming ruff-server and ty-server share handlers.","solutions":["Gate each request on the capabilities returned in the initialize result before sending","Verify the exact method string against the LSP spec / ty's supported methods","Update the client extension and ty server to matching versions","Treat the MethodNotFound response as informational and disable that feature in the client"],"exampleFix":"// before\nawait connection.sendRequest('textDocument/codeLens', params);  // server: MethodNotFound\n\n// after\nif (initResult.capabilities.codeLensProvider) {\n  await connection.sendRequest('textDocument/codeLens', params);\n}","handlingStrategy":"validation","validationCode":"// TS: gate every non-core request on advertised capabilities\nconst caps = initResult.capabilities;\nconst sendIfSupported = (method: string, capability: unknown, params: unknown) =>\n  capability ? client.sendRequest(method, params) : Promise.resolve(null);\n\nawait sendIfSupported('textDocument/codeLens', caps.codeLensProvider, params);","typeGuard":"const isSupportedMethod = (method: string): boolean =>\n  supportedMethodsFromCapabilities(initResult.capabilities).includes(method);","tryCatchPattern":"// If sent anyway, handle the MethodNotFound response explicitly\ntry { await client.sendRequest(method, params); }\ncatch (e: any) {\n  if (e?.code === -32601) { disableFeature(method); return; }\n  throw e;\n}","preventionTips":["Derive feature toggles from the initialize result, never from client-side defaults","Re-read capabilities after every server restart or upgrade","Treat MethodNotFound as 'feature off', not as a user-visible error"],"tags":["lsp","method-not-found","routing","capabilities","version-mismatch"],"backgroundTag":null,"analyzedSha":"672bb4edf04c84f8b0753346359daee4057158f2","analyzedAt":"2026-08-16T08:54:05.464Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}