Fix LSP crash on unparseable cell option YAML by handling null lint result - #1123
Merged
Conversation
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
juliasilge
marked this pull request as ready for review
September 10, 2026 15:54
lionel-
reviewed
Sep 11, 2026
Collaborator
There was a problem hiding this comment.
Since having to handle nulls everywhere is a bit of a footgun, or at least impractical, I'd normalise at the boundary by wrapping getLint() with ?? [] here:
Line 53 in 73a528d
Then we'd keep the current non-nullable signature in the Quarto interface.
WDYT?
Collaborator
Author
|
Oh, that's a better idea, @lionel-. Reworked in de07dbf:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1118 (the upstream report is from posit-dev/positron#15965)
This PR fixes a Quarto LSP server crash that occurred when saving a document containing unparseable YAML in code cell options (for example, a
%%| fig-cap:value containing an unquoted colon). After five crashes in three minutes, the client stops restarting the server and all language features are lost until reload.Root cause
When cell option YAML fails to parse,
getLint()in the bundledvs-code.mjsmodule catches the resultingYAMLException, logs "Error found during linting", and resolves tonull. The on-save diagnostics path inprovideYamlDiagnosticsthen called.map()on thatnullvalue, throwing aTypeErrorthat crashed the language server:The other caller of
getYamlDiagnostics(inapps/lsp/src/custom.ts) already handlednullcorrectly, which is why this only crashed on save.I verified against the reproduction document in #1118, and now saving no longer crashes the server.
A possible follow-up
With this fix, a document with broken cell option YAML silently produces no YAML diagnostics on save (the parse error is only logged to the Output channel). A future improvement could surface the parse error as a diagnostic using the position info in the
YAMLException; that requires changes in the Quarto CLI, where the exception is currently swallowed. The null guard here is still valuable regardless.