openlawlibrary / pygls

A pythonic generic language server
https://pygls.readthedocs.io/en/latest/
Apache License 2.0
568 stars 103 forks source link

Message: TypeError: 'NoneType' object is not iterable #50

Closed Maxattax97 closed 5 years ago

Maxattax97 commented 5 years ago

I'd like to use this to build an LSP for a small language called OpenSCAD, so I started investigating this project (excellent code and docs by the way!). I'm normally a Neovim user, but for sake of better understanding pygls, I installed VS code (in other words, might just be a configuration error) and ran the example JSON language server in debug mode. Unfortunately, I'm quickly met with this error in the debug client running alongside the server:

[Error - 12:11:01 AM] Server initialization failed.
  Message: TypeError: 'NoneType' object is not iterable
  Code: -32602 
[object Object]

Any ideas on how I could get around this? Is this a new error, or is it a common bump in the road?

Thanks in advance.

danixeee commented 5 years ago

Hello @Maxattax97, I have cloned a fresh repo and tried to reproduce the error, but it is working fine on my end. I am using pygls in another project and I didn't notice the issue, as well.

Did you set the python.pythonPath in your .vscode/settings.json?

You can try to debug pygls, by setting a breakpoint here. Since example is using pygls from virtual environment, you have to open protocol.py file from location like YOUR_VENV_PATH/site-packages/pygls/protocol.py.

Thank you for your interests in this project, let me know if you have problems with debugging.

dgreisen commented 5 years ago

If we are able to figure out what is happening, perhaps we can provide a better error message than 'NoneType' object is not iterable to smooth onboarding new developers.

danixeee commented 5 years ago

There are some predefined exceptions and all of them have following fields:

interface ResponseError<D> {
    /**
     * A number indicating the error type that occurred.
     */
    code: number;

    /**
     * A string providing a short description of the error.
     */
    message: string;

    /**
     * A Primitive or Structured value that contains additional
     * information about the error. Can be omitted.
     */
    data?: D;
}

but the data field is displayed as [object Object] for some reason. I will see what I can do regarding that. There is also a log file which can be checked.