From 7eda0750a07f364c48437c7d14462bcb9218bd03 Mon Sep 17 00:00:00 2001 From: zen010101 <60574100+zen010101@users.noreply.github.com> Date: Wed, 17 Dec 2025 18:56:36 +0800 Subject: [PATCH] fix: omit params field when None in JSON-RPC requests/notifications According to JSON-RPC 2.0 specification, the params field must be a structured value (object or array) if present. Sending "params": null violates the spec and causes strict implementations to reject the request. This fix modifies make_request() and make_notification() to omit the params field entirely when params is None, instead of including it as null. --- src/solidlsp/lsp_protocol_handler/server.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/solidlsp/lsp_protocol_handler/server.py b/src/solidlsp/lsp_protocol_handler/server.py index d8ab2718..3a10e10c 100644 --- a/src/solidlsp/lsp_protocol_handler/server.py +++ b/src/solidlsp/lsp_protocol_handler/server.py @@ -92,11 +92,15 @@ def make_error_response(request_id: Any, err: LSPError) -> StringDict: def make_notification(method: str, params: PayloadLike) -> StringDict: - return {"jsonrpc": "2.0", "method": method, "params": params} + # JSON-RPC 2.0: params must be object or array if present, cannot be null + # Some language servers require params to be present, so we send empty object instead of omitting + return {"jsonrpc": "2.0", "method": method, "params": params if params is not None else {}} def make_request(method: str, request_id: Any, params: PayloadLike) -> StringDict: - return {"jsonrpc": "2.0", "method": method, "id": request_id, "params": params} + # JSON-RPC 2.0: params must be object or array if present, cannot be null + # Some language servers require params to be present, so we send empty object instead of omitting + return {"jsonrpc": "2.0", "method": method, "id": request_id, "params": params if params is not None else {}} class StopLoopException(Exception):