Skip to content

Missing structure hook(s?) for notebook types  #228

@alcarney

Description

@alcarney

For example DidOpenNotebookDocumentParams

{
    "notebookDocument": {
        "uri": "untitled:Untitled-1.ipynb?jupyter-notebook",
        "notebookType": "jupyter-notebook",
        "version": 0,
        "cells": [
            {
                "kind": 2,
                "document": "vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D",
                "metadata": {
                    "custom": {
                        "metadata": {}
                    }
                }
            }
        ],
        "metadata": {
            "custom": {
                "cells": [],
                "metadata": {
                    "orig_nbformat": 4,
                    "language_info": {
                        "name": "python"
                    }
                }
            },
            "indentAmount": " "
        }
    },
    "cellTextDocuments": [
        {
            "uri": "vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D",
            "languageId": "python",
            "version": 1,
            "text": ""
        }
    ]
}

Error message

Unable to deserialize message
  + Exception Group Traceback (most recent call last):
  |   File "/var/home/alex/Projects/pygls/pygls/protocol.py", line 415, in _deserialize_message
  |     return self._converter.structure(data, notification_type)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 309, in structure
  |     return self._structure_func.dispatch(cl)(obj, cl)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "<cattrs generated structure lsprotocol.types.NotebookDocumentDidOpenNotification>", line 21, in structure_NotebookDocumentDidOpenNotification
  |     if errors: raise __c_cve('While structuring ' + 'NotebookDocumentDidOpenNotification', errors, __cl)
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  | cattrs.errors.ClassValidationError: While structuring NotebookDocumentDidOpenNotification (1 sub-exception)
  +-+---------------- 1 ----------------
    | Exception Group Traceback (most recent call last):
    |   File "<cattrs generated structure lsprotocol.types.NotebookDocumentDidOpenNotification>", line 5, in structure_NotebookDocumentDidOpenNotification
    |     res['params'] = __c_structure_params(o['params'], __c_type_params)
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "<cattrs generated structure lsprotocol.types.DidOpenNotebookDocumentParams>", line 14, in structure_DidOpenNotebookDocumentParams
    |     if errors: raise __c_cve('While structuring ' + 'DidOpenNotebookDocumentParams', errors, __cl)
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | cattrs.errors.ClassValidationError: While structuring DidOpenNotebookDocumentParams (1 sub-exception)
    | Structuring class NotebookDocumentDidOpenNotification @ attribute params
    +-+---------------- 1 ----------------
      | Exception Group Traceback (most recent call last):
      |   File "<cattrs generated structure lsprotocol.types.DidOpenNotebookDocumentParams>", line 5, in structure_DidOpenNotebookDocumentParams
      |     res['notebook_document'] = __c_structure_notebook_document(o['notebookDocument'], __c_type_notebook_document)
      |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "<cattrs generated structure lsprotocol.types.NotebookDocument>", line 30, in structure_NotebookDocument
      |     if errors: raise __c_cve('While structuring ' + 'NotebookDocument', errors, __cl)
      |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      | cattrs.errors.ClassValidationError: While structuring NotebookDocument (2 sub-exceptions)
      | Structuring class DidOpenNotebookDocumentParams @ attribute notebook_document
      +-+---------------- 1 ----------------
        | Exception Group Traceback (most recent call last):
        |   File "<cattrs generated structure lsprotocol.types.NotebookDocument>", line 20, in structure_NotebookDocument
        |     res['cells'] = __c_structure_cells(o['cells'], __c_type_cells)
        |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 510, in _structure_list
        |     raise IterableValidationError(
        | cattrs.errors.IterableValidationError: While structuring typing.List[lsprotocol.types.NotebookCell] (1 sub-exception)
        | Structuring class NotebookDocument @ attribute cells
        +-+---------------- 1 ----------------
          | Exception Group Traceback (most recent call last):
          |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 502, in _structure_list
          |     res.append(handler(e, elem_type))
          |                ^^^^^^^^^^^^^^^^^^^^^
          |   File "<cattrs generated structure lsprotocol.types.NotebookCell>", line 26, in structure_NotebookCell
          |     if errors: raise __c_cve('While structuring ' + 'NotebookCell', errors, __cl)
          |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          | cattrs.errors.ClassValidationError: While structuring NotebookCell (1 sub-exception)
          | Structuring typing.List[lsprotocol.types.NotebookCell] @ index 0
          +-+---------------- 1 ----------------
            | Traceback (most recent call last):
            |   File "<cattrs generated structure lsprotocol.types.NotebookCell>", line 16, in structure_NotebookCell
            |     res['metadata'] = __c_structure_metadata(o['metadata'], __c_type_metadata)
            |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 574, in _structure_optional
            |     return self._structure_func.dispatch(other)(obj, other)
            |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 377, in _structure_error
            |     raise StructureHandlerNotFoundError(msg, type_=cl)
            | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: <class 'object'>. Register a structure hook for it.
            | Structuring class NotebookCell @ attribute metadata
            +------------------------------------
        +---------------- 2 ----------------
        | Traceback (most recent call last):
        |   File "<cattrs generated structure lsprotocol.types.NotebookDocument>", line 26, in structure_NotebookDocument
        |     res['metadata'] = __c_structure_metadata(o['metadata'], __c_type_metadata)
        |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 574, in _structure_optional
        |     return self._structure_func.dispatch(other)(obj, other)
        |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 377, in _structure_error
        |     raise StructureHandlerNotFoundError(msg, type_=cl)
        | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: <class 'object'>. Register a structure hook for it.
        | Structuring class NotebookDocument @ attribute metadata
        +------------------------------------

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugtriage-needed

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions