Merge pull request #851 from zen010101/fix/jsonrpc-params-null

Fix: Use {} instead of null in params field when None in JSON-RPC requests/notifications
This commit is contained in:
Dominik Jain authored and GitHub committed 2025-12-17 20:50:08 +01:00
commit 9d7f5e5cd2
1 file changed
+6 -2
+6 -2
View File
@@ -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):