yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

Visual Studio Client Integration: Server throws cannot read properties of undefined (reading 'length')

Open varunverma001 opened this issue 2 years ago • 2 comments

Describe the bug

When integrating the Yaml Language Server with Visual Studio I faced an error during the 'textDocument/completion' call to the server. The error is outmsg = "{"jsonrpc":"2.0","id":9,"error":{"code":-32603,"message":"Request textDocument/completion failed with message: Cannot read properties of undefined (reading 'length')"}}" The version of yaml language server is 1.10.0

I tried to attach the yaml language server nodejs process and found that the error is thrown at line 283 of this file https://github.com/redhat-developer/yaml-language-server/blob/1.10.0/src/languageservice/services/yamlCompletion.ts

I fixed this error by changing the condition to 'if (this.customTags && this.customTags.length > 0) {' The schema is fine and gets validated with the same language server. I am happy to provide if required.

Expected Behavior

Even if customTags are not defined the completion should work successfully.

Current Behavior

It throws an error "Request textDocument/completion failed with message: Cannot read properties of undefined (reading 'length')"}}"

Steps to Reproduce

  1. Setup a new VS client
  2. Don't initialize the language server and start it with defaults.
  3. Run the autocompletion on a schema file.

Environment

  • [ yes] Windows
  • [ ] Mac
  • [ ] Linux
  • [ ] other (please specify)

varunverma001 avatar Nov 29 '22 03:11 varunverma001

Adding a permalink to the line https://github.com/redhat-developer/yaml-language-server/blob/878ce94e9b42685e9b9f1b6f044a8ae7235d28a7/src/languageservice/services/yamlCompletion.ts#L283

gorkem avatar Dec 17 '22 16:12 gorkem

I faced a similar problem with helix; looks like pullConfiguration doesn't get called at all

https://github.com/redhat-developer/yaml-language-server/blob/341ab995e9cb37b073920c39930796ed7ae58d21/src/yamlServerInit.ts#L52

thecaralice avatar Feb 24 '24 00:02 thecaralice