Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server fails on unknown enum values #438

Open
jothepro opened this issue Mar 13, 2024 · 3 comments
Open

Server fails on unknown enum values #438

jothepro opened this issue Mar 13, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@jothepro
Copy link

I am currently trying to connect to my Pygls server from Visual Studio.
Unfortunately Visual Studio is sending unexpected values for CompletionItemKind and DiagnosticTag in the initialize message

Contents of the JSON initialize message (trimmed)
{
  "traceparent": "00-54539a4a40ff3248a03ded63822bdf1a-cda15417ab88d44d-01",
  "jsonrpc": "2.0",
  "id": 2,
  "method": "initialize",
  "params": {
    "capabilities": {
      "textDocument": {
        "completion": {
          "completionItemKind": {
            "valueSet": [
              0,
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24,
              25,
              118115,
              118116,
              118117,
              118118,
              118119,
              118120,
              118121,
              118122,
              118123,
              118124,
              118125,
              118126
            ]
          }
        },
        "publishDiagnostics": {
          "tagSupport": {
            "valueSet": [
              1,
              2,
              -1,
              -2
            ]
          }
        }
      }
    }
  }
}

Pygls then raises an exception when processing the message, because values like 118118 do not exist in the CompletionItemKind enum and -1 is not a known DiagnostigTag.

Error report
[ERROR] Unable to deserialize message
  + Exception Group Traceback (most recent call last):
  |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\pygls\protocol\json_rpc.py", line 330, in _deserialize_message
  |     return self._converter.structure(data, request_type)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 332, in structure
  |     return self._structure_func.dispatch(cl)(obj, cl)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "<cattrs generated structure lsprotocol.types.InitializeRequest>", line 26, in structure_InitializeRequest
  |     if errors: raise __c_cve('While structuring ' + 'InitializeRequest', errors, __cl)
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  | cattrs.errors.ClassValidationError: While structuring InitializeRequest (1 sub-exception)
  +-+---------------- 1 ----------------
    | Exception Group Traceback (most recent call last):
    |   File "<cattrs generated structure lsprotocol.types.InitializeRequest>", line 10, in structure_InitializeRequest
    |     res['params'] = __c_structure_params(o['params'], __c_type_params)
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "<cattrs generated structure lsprotocol.types.InitializeParams>", line 63, in structure_InitializeParams
    |     if errors: raise __c_cve('While structuring ' + 'InitializeParams', errors, __cl)
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | cattrs.errors.ClassValidationError: While structuring InitializeParams (1 sub-exception)
    | Structuring class InitializeRequest @ attribute params
    +-+---------------- 1 ----------------
      | Exception Group Traceback (most recent call last):
      |   File "<cattrs generated structure lsprotocol.types.InitializeParams>", line 5, in structure_InitializeParams
      |     res['capabilities'] = __c_structure_capabilities(o['capabilities'], __c_type_capabilities)
      |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "<cattrs generated structure lsprotocol.types.ClientCapabilities>", line 40, in structure_ClientCapabilities
      |     if errors: raise __c_cve('While structuring ' + 'ClientCapabilities', errors, __cl)
      |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      | cattrs.errors.ClassValidationError: While structuring ClientCapabilities (1 sub-exception)
      | Structuring class InitializeParams @ attribute capabilities
      +-+---------------- 1 ----------------
        | Exception Group Traceback (most recent call last):
        |   File "<cattrs generated structure lsprotocol.types.ClientCapabilities>", line 12, in structure_ClientCapabilities
        |     res['text_document'] = __c_structure_text_document(o['textDocument'], __c_type_text_document)
        |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
        |     return self._structure_func.dispatch(other)(obj, other)
        |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |   File "<cattrs generated structure lsprotocol.types.TextDocumentClientCapabilities>", line 190, in structure_TextDocumentClientCapabilities
        |     if errors: raise __c_cve('While structuring ' + 'TextDocumentClientCapabilities', errors, __cl)
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        | cattrs.errors.ClassValidationError: While structuring TextDocumentClientCapabilities (2 sub-exceptions)
        | Structuring class ClientCapabilities @ attribute text_document
        +-+---------------- 1 ----------------
          | Exception Group Traceback (most recent call last):
          |   File "<cattrs generated structure lsprotocol.types.TextDocumentClientCapabilities>", line 12, in structure_TextDocumentClientCapabilities
          |     res['completion'] = __c_structure_completion(o['completion'], __c_type_completion)
          |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
          |     return self._structure_func.dispatch(other)(obj, other)
          |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          |   File "<cattrs generated structure lsprotocol.types.CompletionClientCapabilities>", line 40, in structure_CompletionClientCapabilities
          |     if errors: raise __c_cve('While structuring ' + 'CompletionClientCapabilities', errors, __cl)
          |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          | cattrs.errors.ClassValidationError: While structuring CompletionClientCapabilities (1 sub-exception)
          | Structuring class TextDocumentClientCapabilities @ attribute completion
          +-+---------------- 1 ----------------
            | Exception Group Traceback (most recent call last):
            |   File "<cattrs generated structure lsprotocol.types.CompletionClientCapabilities>", line 18, in structure_CompletionClientCapabilities
            |     res['completion_item_kind'] = __c_structure_completion_item_kind(o['completionItemKind'], __c_type_completion_item_kind)
            |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
            |     return self._structure_func.dispatch(other)(obj, other)
            |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "<cattrs generated structure lsprotocol.types.CompletionClientCapabilitiesCompletionItemKindType>", line 10, in structure_CompletionClientCapabilitiesCompletionItemKindType
            |     if errors: raise __c_cve('While structuring ' + 'CompletionClientCapabilitiesCompletionItemKindType', errors, __cl)
            |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            | cattrs.errors.ClassValidationError: While structuring CompletionClientCapabilitiesCompletionItemKindType (1 sub-exception)
            | Structuring class CompletionClientCapabilities @ attribute completion_item_kind
            +-+---------------- 1 ----------------
              | Exception Group Traceback (most recent call last):
              |   File "<cattrs generated structure lsprotocol.types.CompletionClientCapabilitiesCompletionItemKindType>", line 6, in structure_CompletionClientCapabilitiesCompletionItemKindType
              |     res['value_set'] = __c_structure_value_set(o['valueSet'], __c_type_value_set)
              |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
              |     return self._structure_func.dispatch(other)(obj, other)
              |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 531, in _structure_list
              |     raise IterableValidationError(
              | cattrs.errors.IterableValidationError: While structuring typing.List[lsprotocol.types.CompletionItemKind] (13 sub-exceptions)
              | Structuring class CompletionClientCapabilitiesCompletionItemKindType @ attribute value_set
              +-+---------------- 1 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 0 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 0
                +---------------- 2 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118115 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 26
                +---------------- 3 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118116 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 27
                +---------------- 4 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118117 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 28
                +---------------- 5 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118118 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 29
                +---------------- 6 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118119 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 30
                +---------------- 7 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118120 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 31
                +---------------- 8 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118121 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 32
                +---------------- 9 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118122 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 33
                +---------------- 10 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118123 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 34
                +---------------- 11 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118124 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 35
                +---------------- 12 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118125 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 36
                +---------------- 13 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118126 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 37
                +------------------------------------
          +---------------- 2 ----------------
          | Exception Group Traceback (most recent call last):
          |   File "<cattrs generated structure lsprotocol.types.TextDocumentClientCapabilities>", line 132, in structure_TextDocumentClientCapabilities
          |     res['publish_diagnostics'] = __c_structure_publish_diagnostics(o['publishDiagnostics'], __c_type_publish_diagnostics)
          |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
          |     return self._structure_func.dispatch(other)(obj, other)
          |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          |   File "<cattrs generated structure lsprotocol.types.PublishDiagnosticsClientCapabilities>", line 34, in structure_PublishDiagnosticsClientCapabilities
          |     if errors: raise __c_cve('While structuring ' + 'PublishDiagnosticsClientCapabilities', errors, __cl)
          |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          | cattrs.errors.ClassValidationError: While structuring PublishDiagnosticsClientCapabilities (1 sub-exception)
          | Structuring class TextDocumentClientCapabilities @ attribute publish_diagnostics
          +-+---------------- 1 ----------------
            | Exception Group Traceback (most recent call last):
            |   File "<cattrs generated structure lsprotocol.types.PublishDiagnosticsClientCapabilities>", line 12, in structure_PublishDiagnosticsClientCapabilities
            |     res['tag_support'] = __c_structure_tag_support(o['tagSupport'], __c_type_tag_support)
            |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
            |     return self._structure_func.dispatch(other)(obj, other)
            |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "<cattrs generated structure lsprotocol.types.PublishDiagnosticsClientCapabilitiesTagSupportType>", line 9, in structure_PublishDiagnosticsClientCapabilitiesTagSupportType
            |     if errors: raise __c_cve('While structuring ' + 'PublishDiagnosticsClientCapabilitiesTagSupportType', errors, __cl)
            |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            | cattrs.errors.ClassValidationError: While structuring PublishDiagnosticsClientCapabilitiesTagSupportType (1 sub-exception)
            | Structuring class PublishDiagnosticsClientCapabilities @ attribute tag_support
            +-+---------------- 1 ----------------
              | Exception Group Traceback (most recent call last):
              |   File "<cattrs generated structure lsprotocol.types.PublishDiagnosticsClientCapabilitiesTagSupportType>", line 5, in structure_PublishDiagnosticsClientCapabilitiesTagSupportType
              |     res['value_set'] = __c_structure_value_set(o['valueSet'], __c_type_value_set)
              |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 531, in _structure_list
              |     raise IterableValidationError(
              | cattrs.errors.IterableValidationError: While structuring typing.List[lsprotocol.types.DiagnosticTag] (2 sub-exceptions)
              | Structuring class PublishDiagnosticsClientCapabilitiesTagSupportType @ attribute value_set
              +-+---------------- 1 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: -1 is not a valid DiagnosticTag
                | Structuring typing.List[lsprotocol.types.DiagnosticTag] @ index 2
                +---------------- 2 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: -2 is not a valid DiagnosticTag
                | Structuring typing.List[lsprotocol.types.DiagnosticTag] @ index 3
                +------------------------------------

2024-03-13 22:02:53,491 [ERROR] Error receiving data
  + Exception Group Traceback (most recent call last):
  |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\pygls\protocol\json_rpc.py", line 330, in _deserialize_message
  |     return self._converter.structure(data, request_type)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 332, in structure
  |     return self._structure_func.dispatch(cl)(obj, cl)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "<cattrs generated structure lsprotocol.types.InitializeRequest>", line 26, in structure_InitializeRequest
  |     if errors: raise __c_cve('While structuring ' + 'InitializeRequest', errors, __cl)
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  | cattrs.errors.ClassValidationError: While structuring InitializeRequest (1 sub-exception)
  +-+---------------- 1 ----------------
    | Exception Group Traceback (most recent call last):
    |   File "<cattrs generated structure lsprotocol.types.InitializeRequest>", line 10, in structure_InitializeRequest
    |     res['params'] = __c_structure_params(o['params'], __c_type_params)
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "<cattrs generated structure lsprotocol.types.InitializeParams>", line 63, in structure_InitializeParams
    |     if errors: raise __c_cve('While structuring ' + 'InitializeParams', errors, __cl)
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | cattrs.errors.ClassValidationError: While structuring InitializeParams (1 sub-exception)
    | Structuring class InitializeRequest @ attribute params
    +-+---------------- 1 ----------------
      | Exception Group Traceback (most recent call last):
      |   File "<cattrs generated structure lsprotocol.types.InitializeParams>", line 5, in structure_InitializeParams
      |     res['capabilities'] = __c_structure_capabilities(o['capabilities'], __c_type_capabilities)
      |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "<cattrs generated structure lsprotocol.types.ClientCapabilities>", line 40, in structure_ClientCapabilities
      |     if errors: raise __c_cve('While structuring ' + 'ClientCapabilities', errors, __cl)
      |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      | cattrs.errors.ClassValidationError: While structuring ClientCapabilities (1 sub-exception)
      | Structuring class InitializeParams @ attribute capabilities
      +-+---------------- 1 ----------------
        | Exception Group Traceback (most recent call last):
        |   File "<cattrs generated structure lsprotocol.types.ClientCapabilities>", line 12, in structure_ClientCapabilities
        |     res['text_document'] = __c_structure_text_document(o['textDocument'], __c_type_text_document)
        |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
        |     return self._structure_func.dispatch(other)(obj, other)
        |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |   File "<cattrs generated structure lsprotocol.types.TextDocumentClientCapabilities>", line 190, in structure_TextDocumentClientCapabilities
        |     if errors: raise __c_cve('While structuring ' + 'TextDocumentClientCapabilities', errors, __cl)
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        | cattrs.errors.ClassValidationError: While structuring TextDocumentClientCapabilities (2 sub-exceptions)
        | Structuring class ClientCapabilities @ attribute text_document
        +-+---------------- 1 ----------------
          | Exception Group Traceback (most recent call last):
          |   File "<cattrs generated structure lsprotocol.types.TextDocumentClientCapabilities>", line 12, in structure_TextDocumentClientCapabilities
          |     res['completion'] = __c_structure_completion(o['completion'], __c_type_completion)
          |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
          |     return self._structure_func.dispatch(other)(obj, other)
          |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          |   File "<cattrs generated structure lsprotocol.types.CompletionClientCapabilities>", line 40, in structure_CompletionClientCapabilities
          |     if errors: raise __c_cve('While structuring ' + 'CompletionClientCapabilities', errors, __cl)
          |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          | cattrs.errors.ClassValidationError: While structuring CompletionClientCapabilities (1 sub-exception)
          | Structuring class TextDocumentClientCapabilities @ attribute completion
          +-+---------------- 1 ----------------
            | Exception Group Traceback (most recent call last):
            |   File "<cattrs generated structure lsprotocol.types.CompletionClientCapabilities>", line 18, in structure_CompletionClientCapabilities
            |     res['completion_item_kind'] = __c_structure_completion_item_kind(o['completionItemKind'], __c_type_completion_item_kind)
            |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
            |     return self._structure_func.dispatch(other)(obj, other)
            |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "<cattrs generated structure lsprotocol.types.CompletionClientCapabilitiesCompletionItemKindType>", line 10, in structure_CompletionClientCapabilitiesCompletionItemKindType
            |     if errors: raise __c_cve('While structuring ' + 'CompletionClientCapabilitiesCompletionItemKindType', errors, __cl)
            |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            | cattrs.errors.ClassValidationError: While structuring CompletionClientCapabilitiesCompletionItemKindType (1 sub-exception)
            | Structuring class CompletionClientCapabilities @ attribute completion_item_kind
            +-+---------------- 1 ----------------
              | Exception Group Traceback (most recent call last):
              |   File "<cattrs generated structure lsprotocol.types.CompletionClientCapabilitiesCompletionItemKindType>", line 6, in structure_CompletionClientCapabilitiesCompletionItemKindType
              |     res['value_set'] = __c_structure_value_set(o['valueSet'], __c_type_value_set)
              |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
              |     return self._structure_func.dispatch(other)(obj, other)
              |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 531, in _structure_list
              |     raise IterableValidationError(
              | cattrs.errors.IterableValidationError: While structuring typing.List[lsprotocol.types.CompletionItemKind] (13 sub-exceptions)
              | Structuring class CompletionClientCapabilitiesCompletionItemKindType @ attribute value_set
              +-+---------------- 1 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 0 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 0
                +---------------- 2 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118115 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 26
                +---------------- 3 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118116 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 27
                +---------------- 4 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118117 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 28
                +---------------- 5 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118118 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 29
                +---------------- 6 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118119 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 30
                +---------------- 7 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118120 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 31
                +---------------- 8 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118121 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 32
                +---------------- 9 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118122 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 33
                +---------------- 10 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118123 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 34
                +---------------- 11 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118124 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 35
                +---------------- 12 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118125 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 36
                +---------------- 13 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: 118126 is not a valid CompletionItemKind
                | Structuring typing.List[lsprotocol.types.CompletionItemKind] @ index 37
                +------------------------------------
          +---------------- 2 ----------------
          | Exception Group Traceback (most recent call last):
          |   File "<cattrs generated structure lsprotocol.types.TextDocumentClientCapabilities>", line 132, in structure_TextDocumentClientCapabilities
          |     res['publish_diagnostics'] = __c_structure_publish_diagnostics(o['publishDiagnostics'], __c_type_publish_diagnostics)
          |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
          |     return self._structure_func.dispatch(other)(obj, other)
          |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          |   File "<cattrs generated structure lsprotocol.types.PublishDiagnosticsClientCapabilities>", line 34, in structure_PublishDiagnosticsClientCapabilities
          |     if errors: raise __c_cve('While structuring ' + 'PublishDiagnosticsClientCapabilities', errors, __cl)
          |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          | cattrs.errors.ClassValidationError: While structuring PublishDiagnosticsClientCapabilities (1 sub-exception)
          | Structuring class TextDocumentClientCapabilities @ attribute publish_diagnostics
          +-+---------------- 1 ----------------
            | Exception Group Traceback (most recent call last):
            |   File "<cattrs generated structure lsprotocol.types.PublishDiagnosticsClientCapabilities>", line 12, in structure_PublishDiagnosticsClientCapabilities
            |     res['tag_support'] = __c_structure_tag_support(o['tagSupport'], __c_type_tag_support)
            |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 627, in _structure_optional
            |     return self._structure_func.dispatch(other)(obj, other)
            |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "<cattrs generated structure lsprotocol.types.PublishDiagnosticsClientCapabilitiesTagSupportType>", line 9, in structure_PublishDiagnosticsClientCapabilitiesTagSupportType
            |     if errors: raise __c_cve('While structuring ' + 'PublishDiagnosticsClientCapabilitiesTagSupportType', errors, __cl)
            |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            | cattrs.errors.ClassValidationError: While structuring PublishDiagnosticsClientCapabilitiesTagSupportType (1 sub-exception)
            | Structuring class PublishDiagnosticsClientCapabilities @ attribute tag_support
            +-+---------------- 1 ----------------
              | Exception Group Traceback (most recent call last):
              |   File "<cattrs generated structure lsprotocol.types.PublishDiagnosticsClientCapabilitiesTagSupportType>", line 5, in structure_PublishDiagnosticsClientCapabilitiesTagSupportType
              |     res['value_set'] = __c_structure_value_set(o['valueSet'], __c_type_value_set)
              |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 531, in _structure_list
              |     raise IterableValidationError(
              | cattrs.errors.IterableValidationError: While structuring typing.List[lsprotocol.types.DiagnosticTag] (2 sub-exceptions)
              | Structuring class PublishDiagnosticsClientCapabilitiesTagSupportType @ attribute value_set
              +-+---------------- 1 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: -1 is not a valid DiagnosticTag
                | Structuring typing.List[lsprotocol.types.DiagnosticTag] @ index 2
                +---------------- 2 ----------------
                | Traceback (most recent call last):
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 521, in _structure_list
                |     res.append(handler(e, elem_type))
                |                ^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\site-packages\cattrs\converters.py", line 430, in _structure_call
                |     return cl(obj)
                |            ^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 712, in __call__
                |     return cls.__new__(cls, value)
                |            ^^^^^^^^^^^^^^^^^^^^^^^
                |   File "C:\Users\Johannes\AppData\Local\Programs\Python\Python311\Lib\enum.py", line 1135, in __new__
                |     raise ve_exc
                | ValueError: -2 is not a valid DiagnosticTag
                | Structuring typing.List[lsprotocol.types.DiagnosticTag] @ index 3
                +------------------------------------

In case of the CompletionItemKind it seems like the Visual Studio Client is promoting some proprietary completion item types to the language server. The meaning of the additional CompletionItemKind is documented here.

In the LSP Specification, the handling of unknown values is specified as follows:

To support the evolution of enumerations the using side of an enumeration shouldn’t fail on an enumeration value it doesn’t know. It should simply ignore it as a value it can use and try to do its best to preserve the value on round trips.

Based on this information I would expect Pygls to ignore the additional values that Visual Studio is sending, and not fail with an exception.

Reproducing the exact problem could be a bit complicated, as it requires setting up a Visual Studio extension that launches a Pygls language server. I can provide an MVP if requested.

@alcarney
Copy link
Collaborator

This issue stems from the fact we rely on lsprotocol for our type definitions, which in turn relies on the protocol's metaModel.json in order to generate them. The perhaps "right way" to fix this would be to get lsprotocol to pick a more relaxed type that permits these extra values - which might take some time to propagate through to a pygls release

However, in the meantime, you should be able around this issue by providing your own customised cattrs converter instance (see this comment for more context)

Using the following code I was able to resolve the errors thrown by the extra CompletionItemKind values

from lsprotocol import types

from pygls.protocol import default_converter
from pygls.server import LanguageServer


def my_converter():
    converter = default_converter()

    def completion_item_kind_hook(obj, type_):
        try:
            return types.CompletionItemKind(obj)
        except ValueError:
            return obj

    converter.register_structure_hook(
        types.CompletionItemKind, completion_item_kind_hook
    )

    return converter


server = LanguageServer("example-server", "v0.1", converter_factory=my_converter)

Any unknown values will now show up as a plain int instead of an instance of the CompletionItemKind enum.

I imagine a similar approach will also allow you to resolve the issue with DiagnosticTag.

@alcarney
Copy link
Collaborator

It's probably worth mentioning though, that depending on if you intend to use these values in messages yourself you could run into other issues - I had to use a few hacks in my code to reproduce your error....

    # Override the type lookup mechanism
    get_type = client.protocol.get_message_type
    client.protocol.get_message_type = lambda m: (
        JsonRPCRequestMessage if m == "initialize" else get_type(m)
    )

    response = await client.protocol.send_request_async(
        "initialize",
        dict(
            capabilities=dict(
                textDocument=dict(
                    completion=dict(
                        completionItemKind=dict(
                            valueSet=[
                                # fmt: off
                                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                                11, 12, 13, 14, 15, 16, 17, 18, 19,
                                20, 21, 22, 23, 24, 25, 118115,
                                118116, 118117, 118118, 118119,
                                118120, 118121, 118122, 118123,
                                118124, 118125, 118126,
                                # fmt: on
                            ]
                        )
                    )
                )
            ),
            root_uri=uris.from_fs_path(root_dir),
        ),
    )

@jothepro
Copy link
Author

Thanks for the super quick response! I can confirm that the suggested workaround does solve the problem for me!

I'm not really interested in the additional, proprietary values. IMO it's a bit strange that Visual Studio is sending them in the first place, because for them to have any semantic meaning the language-server would need to know that it is connected to Visual Studio? 🤔

jothepro added a commit to pydjinni/pydjinni that referenced this issue Mar 14, 2024
Visual Studio is sending unexpected values for  CompletionItemKind and DiagnosticTag.

This workaround fixes interoperability with Visual Studio,
a permanent solution might be coming soon:

openlawlibrary/pygls#438
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants