{"record":{"id":"173a894b80cd363b","repo":"Kuberwastaken/claurst","slug":"lsp-error-from","errorCode":null,"errorMessage":"LSP error from {}: {}","messagePattern":"LSP error from (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-rust/crates/core/src/lsp.rs","lineNumber":333,"sourceCode":"            tokio::time::timeout(std::time::Duration::from_secs(30), rx)\r\n                .await\r\n                .map_err(|_| {\r\n                    anyhow::anyhow!(\r\n                        \"LSP request '{}' timed out (server: {})\",\r\n                        method,\r\n                        self.server_name\r\n                    )\r\n                })?\r\n                .map_err(|_| {\r\n                    anyhow::anyhow!(\r\n                        \"LSP request '{}' channel closed (server: {})\",\r\n                        method,\r\n                        self.server_name\r\n                    )\r\n                })?;\r\n\r\n        if let Some(err) = response.get(\"error\") {\r\n            return Err(anyhow::anyhow!(\r\n                \"LSP error from {}: {}\",\r\n                self.server_name,\r\n                err\r\n            ));\r\n        }\r\n        Ok(response[\"result\"].clone())\r\n    }\r\n\r\n    /// Send a JSON-RPC notification (fire-and-forget, no response expected).\r\n    async fn send_notification_inner(\r\n        &self,\r\n        method: &str,\r\n        params: serde_json::Value,\r\n    ) -> anyhow::Result<()> {\r\n        let msg = json!({\r\n            \"jsonrpc\": \"2.0\",\r\n            \"method\": method,\r\n            \"params\": params,\r","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/core/src/lsp.rs#L315-L351","documentation":"Thrown in `LspClient::send_request_inner` when the JSON-RPC response from the language server contains an `error` member. This is the server's own JSON-RPC error object (code + message) surfaced verbatim to the caller. The request reached the server and was understood, but the server rejected it.","triggerScenarios":"Any request via send_request_inner (initialize, hover, definition, references, document_symbols, shutdown) where the server replies with a JSON-RPC error — e.g. method not supported (code -32601), invalid params, or request before initialize.","commonSituations":"Hover/definition requested on a server that lacks the capability; position out of range for some strict servers; request sent before the `initialize` handshake completed; server's initializationOptions malformed so it rejects requests.","solutions":["Read the embedded JSON-RPC `error` object in the message to identify the server-side code and message.","Ensure `initialize(root_uri)` completed successfully before issuing feature requests.","Check the server's declared capabilities and avoid calling unsupported methods (e.g. hover on a server without hoverProvider).","Fix the request params (position, uri) or the server's initializationOptions in settings."],"exampleFix":"// before: assuming any server supports hover\nlet hover = manager.hover(path, root, line, col).await?;\n// after: degrade gracefully when server reports a JSON-RPC error\nlet hover = manager.hover(path, root, line, col).await\n    .unwrap_or_else(|e| { tracing::warn!(\"hover unavailable: {e}\"); None });","handlingStrategy":"try-catch","validationCode":"// Only call methods the server advertises (after initialize, inspect result.capabilities)\nlet caps = initialize_response[\"result\"][\"capabilities\"].clone();\nlet supports_hover = caps.get(\"hoverProvider\").and_then(|v| v.as_bool()).unwrap_or(false);","typeGuard":null,"tryCatchPattern":"let result = manager.hover(path, root, line, col).await\n    .map_err(|e| { tracing::debug!(\"LSP server rejected request: {e}\"); e })\n    .unwrap_or(None); // degrade to no-hover instead of failing the session","preventionTips":["Always complete the initialize handshake before feature requests.","Gate calls on the server's advertised capabilities.","Log the embedded JSON-RPC error object to spot protocol mismatches early."],"tags":["lsp","jsonrpc","protocol-error","rust"],"backgroundTag":"api-error-response","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}