Skip to content

fix(language-service): prevent crash on malformed html.customData configuration#6127

Open
WangKepeople wants to merge 3 commits into
vuejs:masterfrom
WangKepeople:fix/vue-template-null-custom-data
Open

fix(language-service): prevent crash on malformed html.customData configuration#6127
WangKepeople wants to merge 3 commits into
vuejs:masterfrom
WangKepeople:fix/vue-template-null-custom-data

Conversation

@WangKepeople

Copy link
Copy Markdown

Description

Fixes a server crash (TypeError: paths is not iterable) when an LSP client returns an array containing null elements (e.g., [null]) for the unconfigured html.customData option.

Context

Some non-VS Code LSP clients (such as Emacs Eglot) respond to workspace/configuration requests with [null] when a configuration section is not explicitly set in the workspace settings.

Currently, (await context.env.getConfiguration?.("html.customData")) ?? [] evaluates to [null] (since [null] is truthy), causing the subsequent for (const path of paths) loop to assign null to path and throw a runtime error inside getCustomData().

Changes

  • Safely check and filter out null or falsy items from the html.customData array using Array.isArray(rawPaths) ? rawPaths.filter(Boolean) : [].

Comment thread packages/language-service/lib/plugins/vue-template.ts Outdated
Comment thread packages/language-service/lib/plugins/vue-template.ts Outdated
@KazariEX

Copy link
Copy Markdown
Member

The error report seems to indicate that paths itself is not iterable. If it were [null], it should not produce TypeError: paths is not iterable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants