{"record":{"id":"190dcc441fc8e3db","repo":"zed-industries/zed","slug":"failed-to-deserialize-response","errorCode":null,"errorMessage":"failed to deserialize response","messagePattern":"failed to deserialize response","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/lsp/src/lsp.rs","lineNumber":1552,"sourceCode":"            .lock()\n            .as_mut()\n            .context(\"server shut down\")\n            .map(|handlers| {\n                let executor = executor.clone();\n                handlers.insert(\n                    RequestId::Int(id),\n                    Box::new(move |result| {\n                        executor\n                            .spawn(async move {\n                                let response = match result {\n                                    Ok(response) => match deserialize_result(&response) {\n                                        Ok(deserialized) => Ok(deserialized),\n                                        Err(error) => {\n                                            log::error!(\"failed to deserialize response from language server: {}. response from language server: {:?}\", error, response);\n                                            Err(error).context(\"failed to deserialize response\")\n                                        }\n                                    }\n                                    Err(error) => Err(anyhow::Error::new(error)),\n                                };\n                                tx.send(response).ok();\n                            })\n                    }),\n                );\n            });\n\n        let send = outbound_tx\n            .try_send(message)\n            .context(\"failed to write to language server's stdin\");\n\n        let response_handlers = Arc::clone(response_handlers);\n        let notification_serializers = notification_serializers.downgrade();\n        let started = Instant::now();\n        LspRequest::new(id, async move {\n            if let Err(e) = handle_response {\n                return ConnectionResult::Result(Err(e));\n            }","sourceCodeStart":1534,"sourceCodeEnd":1570,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/lsp/src/lsp.rs#L1534-L1570","documentation":"This error occurs in Zed's LSP client when a JSON-RPC response from a language server cannot be deserialized into the expected strongly-typed result of the request (e.g. a `lsp::CompletionResponse` or `lsp::Hover`). The client wraps the serde/serde_json error with the context string \"failed to deserialize response\", and the future returned by `LanguageServer::request` resolves to this error. It indicates the server replied, but the payload shape did not match the LSP schema Zed expected — usually a server that emits non-conformant JSON, or a Zed-side type mismatch between the lsp-types version and what the server sends.","triggerScenarios":"Calling `LanguageServer::request::<T>()` (crates/lsp/src/lsp.rs `request_internal_with_timer`, line 1542 `deserialize_result`) where the server's response body fails `serde_json` deserialization into `T::Result` — e.g. a server returning `null` result for a non-nullable request type, a completion item with wrong-typed fields, unknown enum variant, or missing required fields.","commonSituations":"Using a language server version that emits LSP 3.17+ fields Zed's pinned lsp-types version rejects or a server with known spec violations (e.g. some Rust Analyzer/clangd/gopls edge responses, jdtls returning null results for textDocument/documentSymbol); server extensions that add fields with wrong types; running a dev build of a language server against a newer Zed or vice versa.","solutions":["Check the Zed log (the `log::error!` at crates/lsp/src/lsp.rs:1545 includes the raw server response) to see the exact serde error and offending payload.","Update the language server binary to a released version; non-conformant responses are often fixed upstream.","Update Zed (or lsp-types/zed's LSP adapter) so its expected response types match the server's LSP dialect.","If a specific server is at fault, file/lookup an issue on the server; as a workaround, disable or downgrade that extension/server version.","If you develop the adapter (languages/src/*_language_server), normalize the server's quirks in the adapter before the response reaches the typed request path."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// No pre-call validation is possible: the payload shape is decided by the server.\n// Log the raw response at the adapter layer to make failures debuggable:\ntracing::debug!(response = %raw_response_json, \"server response for {}\", T::METHOD);","typeGuard":"fn is_deserialize_failure(err: &anyhow::Error) -> bool {\n    err.chain().any(|c| c.to_string().contains(\"failed to deserialize response\"))\n}","tryCatchPattern":"match server.request::<lsp::request::Completion>(&params).await {\n    Ok(result) => result,\n    Err(err) if is_deserialize_failure(&err) => {\n        log::warn!(\"server sent non-conformant response: {err:#}\");\n        Default::default() // fall back to empty completion result\n    }\n    Err(err) => return Err(err),\n}","preventionTips":["Keep Zed and its language server binaries updated together so lsp-types expectations match the server.","When a server misbehaves, read the full raw response in Zed's log line \"failed to deserialize response from language server\" to identify the offending field.","Pin known-good language server versions in project settings for servers with LSP conformance bugs.","Report conformance bugs upstream with the logged raw response."],"tags":["lsp","serialization","json","language-server"],"backgroundTag":"json-deserialization-failed","analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-09-05T10:33:00.413Z","contentChangedAt":"2026-09-05T10:33:00.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}