{"record":{"id":"76026a2d350842ec","repo":"Hmbown/CodeWhale","slug":"lsp-initialize-response-is-missing-server-capabilities","errorCode":null,"errorMessage":"LSP initialize response is missing server capabilities","messagePattern":"LSP initialize response is missing server capabilities","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/lsp/client.rs","lineNumber":288,"sourceCode":"            diagnostics_rx: AsyncMutex::new(rx_diag),\n            pending,\n            next_id: AsyncMutex::new(1),\n            language_id: language_id.to_string(),\n            opened: AsyncMutex::new(HashMap::new()),\n        };\n        let result = transport.request(\"initialize\", json!({\n            \"processId\": std::process::id(),\n            \"rootUri\": uri_from_path(&workspace),\n            \"capabilities\": {\n                \"general\": { \"positionEncodings\": [\"utf-16\"] },\n                \"textDocument\": {\n                    \"publishDiagnostics\": { \"relatedInformation\": false, \"versionSupport\": true }\n                }\n            },\n            \"workspaceFolders\": [{\"uri\": uri_from_path(&workspace), \"name\": \"workspace\"}]\n        }), initialize_wait).await.context(\"LSP initialization failed\")?;\n        if !result.get(\"capabilities\").is_some_and(Value::is_object) {\n            return Err(anyhow!(\n                \"LSP initialize response is missing server capabilities\"\n            ));\n        }\n        if result\n            .pointer(\"/capabilities/positionEncoding\")\n            .is_some_and(|encoding| encoding.as_str() != Some(\"utf-16\"))\n        {\n            return Err(anyhow!(\"LSP server must use UTF-16 positions\"));\n        }\n        timeout(\n            initialize_wait,\n            send_message(\n                &transport.tx_outbound,\n                &json!({\n                    \"jsonrpc\": \"2.0\", \"method\": \"initialized\", \"params\": {}\n                }),\n            ),\n        )","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lsp/client.rs#L270-L306","documentation":"After sending the `initialize` request, spawn_with_timeout requires the response to contain an object under `capabilities`. A server that omits it is non-conformant or answered with something unexpected, so startup is aborted.","triggerScenarios":"`spawn_with_timeout` receiving an initialize reply without a `capabilities` object — e.g. the server sent an error response, a notification instead of a reply, or is an old/non-conformant LSP server.","commonSituations":"Pointing the client at a binary that is not a real LSP server; server crashes during initialize and an error object is returned; protocol version mismatch.","solutions":["Log the full initialize response to see what actually came back","Verify the configured server command is a real LSP server at a supported version","Check whether the initialize call returned a JSON-RPC error and surface that instead","Update or replace the LSP server"],"exampleFix":"// before\nif !result.get(\"capabilities\").is_some_and(Value::is_object) {\n    return Err(anyhow!(\"LSP initialize response is missing server capabilities\"));\n}\n// after\nif let Some(err) = result.get(\"error\") {\n    return Err(anyhow!(\"LSP initialization failed: {err}\"));\n}\nif !result.get(\"capabilities\").is_some_and(Value::is_object) {\n    return Err(anyhow!(\"LSP initialize response is missing server capabilities: {result}\"));\n}","handlingStrategy":"try-catch","validationCode":"const r = await initializeOnce();\nif (!(r && typeof r === 'object' && r.capabilities && typeof r.capabilities === 'object')) throw new Error('non-conformant LSP server');","typeGuard":"fn has_capabilities(v: &Value) -> bool { v.get(\"capabilities\").map(|c| c.is_object()).unwrap_or(false) }","tryCatchPattern":"match spawn_with_timeout(...).await {\n    Err(e) if e.to_string().contains(\"missing server capabilities\") => {\n        eprintln!(\"server not LSP-conformant; check command and version\");\n    }\n    other => other,\n}","preventionTips":["Validate the server command resolves to a real LSP binary at startup","Include the raw response in the error context for diagnosis","Pin supported server versions"],"tags":["lsp","initialize","protocol"],"backgroundTag":"unexpected-response-shape","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}