redhat-developer / yaml-language-server

Language Server for YAML Files
MIT License
1.01k stars 244 forks source link

fix: crash when url is undefined #954

Closed GustavEikaas closed 1 month ago

GustavEikaas commented 3 months ago

What does this PR do?

When the url property in the schema store is undefined the program crashes. It should also be considered adding some useful logging. Enabling schemastore without an url doesnt seem to do much.

What issues does this PR fix or reference?

I couldnt find any issues referencing this. I can make one if thats wanted

Is it tested? How?

Tested it locally. Try installing the package and running it with yaml.schemastore.enabled = true without specifying an url. After adding the ? it wont crash anymore

Stacktrace

  1. setConfiguration [ERROR][2024-03-15 22:13:53] ...lsp/handlers.lua:535 "TypeError: Cannot read properties of undefined (reading 'length')\n at SettingsHandler.setConfiguration (C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\yaml-language-server\\out\\server\\src\\languageserver\\handlers\\settingsHandlers.js:80:43)\n at SettingsHandler.pullConfiguration (C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\yaml-language-server\\out\\server\\src\\languageserver\\handlers\\settingsHandlers.js:58:16)"

  2. setSchemaStoreSettingsIfNotSet [ERROR][2024-03-15 22:29:16] ...lsp/handlers.lua:535 "TypeError: Cannot read properties of undefined (reading 'length')\n at SettingsHandler.setSchemaStoreSettingsIfNotSet (C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\yaml-language-server\\out\\server\\src\\languageserver\\handlers\\settingsHandlers.js:166:42)\n at SettingsHandler.setConfiguration (C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\yaml-language-server\\out\\server\\src\\languageserver\\handlers\\settingsHandlers.js:135:16)\n at SettingsHandler.pullConfiguration (C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\yaml-language-server\\out\\server\\src\\languageserver\\handlers\\settingsHandlers.js:58:16)"

msivasubramaniaan commented 1 month ago

@GustavEikaas Build is failing. Can you please fix and update the PR

GustavEikaas commented 1 month ago

@msivasubramaniaan Linting fixed ✅

coveralls commented 1 month ago

Coverage Status

coverage: 84.174%. remained the same when pulling 9d981914a8427706f298cc9461f552e0dae3017a on GustavEikaas:fix/crash-when-url-not-present into 0871dc12bb1d092bd08831dbe1f2179c41f55342 on redhat-developer:main.