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

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

Closed
alcarney opened this issue Jun 27, 2023 · 1 comment · Fixed by #229
Closed

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

alcarney opened this issue Jun 27, 2023 · 1 comment · Fixed by #229
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed

Comments

@alcarney
Copy link
Contributor

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
        +------------------------------------
@karthiknadig
Copy link
Member

That looks like a bug, either is how metadata object is defined or in the structuring hook (as you noted). I will investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants