[ERROR][2024-07-01 08:50:31] .../vim/lsp/rpc.lua:770 "rpc" "/path/to/ruff-lsp" "stderr" "Error receiving data
+ Exception Group Traceback (most recent call last):
| File "/path/to/ruff-lsp/venv/lib/python3.12/site-packages/pygls/protocol/json_rpc.py", line 330, in _deserialize_message
| return self._converter.structure(data, request_type)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/path/to/ruff-lsp/venv/lib/python3.12/site-packages/cattrs/converters.py", line 332, in structure
| return self._structure_func.dispatch(cl)(obj, cl)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "<cattrs generated structure lsprotocol.types.TextDocumentCodeActionRequest>", line 26, in structure_TextDocumentCodeActionRequest
| if errors: raise __c_cve('While structuring ' + 'TextDocumentCodeActionRequest', errors, __cl)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| cattrs.errors.ClassValidationError: While structuring TextDocumentCodeActionRequest (1 sub-exception)
+-+---------------- 1 ----------------
| Exception Group Traceback (most recent call last):
| File "<cattrs generated structure lsprotocol.types.TextDocumentCodeActionRequest>", line 10, in structure_TextDocumentCodeActionRequest
| res['params'] = __c_structure_params(o['params'], __c_type_params)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "<cattrs generated structure lsprotocol.types.CodeActionParams>", line 31, in structure_CodeActionParams
| if errors: raise __c_cve('While structuring ' + 'CodeActionParams', errors, __cl)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| cattrs.errors.ClassValidationError: While structuring CodeActionParams (1 sub-exception)
| Structuring class TextDocumentCodeActionRequest @ attribute params
+-+---------------- 1 ----------------
| Exception Group Traceback (most recent call last):
| File "<cattrs generated structure lsprotocol.types.CodeActionParams>", line 15, in structure_CodeActionParams
| res['context'] = __c_structure_context(o['context'], __c_type_context)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "<cattrs generated structure lsprotocol.types.CodeActionContext>", line 21, in structure_CodeActionContext
| if errors: raise __c_cve('While structuring ' + 'CodeActionContext', errors, __cl)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| cattrs.errors.ClassValidationError: While structuring CodeActionContext (1 sub-exception)
| Structuring class CodeActionParams @ attribute context
+-+---------------- 1 ----------------
| Exception Group Traceback (most recent call last):
| File "<cattrs generated structure lsprotocol.types.CodeActionContext>", line 5, in structure_CodeActionContext
| res['diagnostics'] = __c_structure_diagnostics(o['diagnostics'], __c_type_diagnostics)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/path/to/ruff-lsp/venv/lib/python3.12/site-packages/cattrs/converters.py", line 531, in _structure_list
| raise IterableValidationError(
| cattrs.errors.IterableValidationError: While structuring typing.List[lsprotocol.types.Diagnostic] (1 sub-exception)
| Structuring class CodeActionContext @ attribute diagnostics
+-+---------------- 1 ----------------
| Exception Group Traceback (most recent call last):
| File "/path/to/ruff-lsp/venv/lib/python3.12/site-packages/cattrs/converters.py", line 521, in _structure_list
| res.append(handler(e, elem_type))
| ^^^^^^^^^^^^^^^^^^^^^
| File "<cattrs generated structure lsprotocol.types.Diagnostic>", line 56, in structure_Diagnostic
| if errors: raise __c_cve('While structuring ' + 'Diagnostic', errors, __cl)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| cattrs.errors.ClassValidationError: While structuring Diagnostic (1 sub-exception)
| Structuring typing.List[lsprotocol.types.Diagnostic] @ index 0
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "<cattrs generated structure lsprotocol.types.Diagnostic>", line 5, in structure_Diagnostic
| res['range'] = __c_structure_range(o['range'], __c_type_range)
| ~^^^^^^^^^
| KeyError: 'range'
| Structuring class Diagnostic @ attribute range
+------------------------------------
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/path/to/ruff-lsp/venv/lib/python3.12/site-packages/pygls/protocol/json_rpc.py", line 443, in data_received
self._data_received(data)
File "/path/to/ruff-lsp/venv/lib/python3.12/site-packages/pygls/protocol/json_rpc.py", line 475, in _data_received
json.loads(
File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/__init__.py", line 359, in loads
return cls(**kw).decode(s)
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/ruff-lsp/venv/lib/python3.12/site-packages/pygls/protocol/json_rpc.py", line 344, in _deserialize_message
raise JsonRpcInvalidParams() from exc
pygls.exceptions.JsonRpcInvalidParams: Invalid Params
Bug Report: JSON-RPC Deserialization Error in
ruff-lspSummary:
Encountering a JSON-RPC deserialization error in
ruff-lspwhen using it with Neovim. The error seems to occur while handling aTextDocumentCodeActionRequestmessage, specifically within theCodeActionContextof aDiagnosticobject where therangekey is missing.Environment:
Operating System: macOS
**Neovim Version:**NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1716656478
Run "nvim -V1 -v" for more info
ruff-lsp Version:: latest
Python Version: 3.12.4
Installed via: Mason
Error Message:
Steps to Reproduce:
ruff-lspusing Mason in Neovim.ruff-lspas the language server.TextDocumentCodeActionRequest.Expected Behavior:
The
ruff-lspshould successfully handleTextDocumentCodeActionRequestmessages without deserialization errors.Additional Information:
Diagnosticobjects withinTextDocumentCodeActionRequest, specifically the absence of therangekey.Possible Workarounds:
Diagnosticobjects include arangekey.ruff-lspand its dependencies to the latest versions.Attachments: