Skip to content

fix(builtins/diagnostics/vacuum): crash on malformed file - #317

Merged
barrettruth merged 1 commit into
nvimtools:mainfrom
iyxan23:fix-vacuum-diagnostics
Jan 15, 2026
Merged

barrettruth merged 1 commit into
nvimtools:mainfrom
iyxan23:fix-vacuum-diagnostics

Conversation

@iyxan23

@iyxan23 iyxan23 commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR fixes a crash in none-ls' vacuum diagnostics when vacuum returns a resultSet without a results field (e.g. on malformed OpenAPI input).

I discovered this bug while I was editing an openapi document, none-ls would crash randomly with the following error:

[null-ls] failed to run generator: ...none-ls.nvim/lua/null-ls/builtins/diagnostics/vacuum.lua:34: bad argument #1 to 'ipairs' (table expected, got nil)

At first I was puzzled, but later I started to notice it only happens when the file is malformed (e.g. when I was pasting a line with improper indentation).

I thought of exploring the referenced file, and saw this:

on_output = function(params)
local diags = {}
if params.output.resultSet.results == vim.NIL then
return diags
end
for _, d in ipairs(params.output.resultSet.results) do
table.insert(diags, {
row = d.range.start.line,
col = d.range.start.character,

I appended a new expression that checks whether params.output.resultSet.results == nil like such:

if params.output.resultSet.results == vim.NIL or params.output.resultSet.results == nil then
    return diags
end

And somehow it started working like normal... so yeah.

After some bit of digging, I found that the commit ba06829 introduced the if-statement. So I decided to test running vacuum's report command and compared the output for the older version (of the commit) to the latest version.

This is the old version:

$ # Older version of vacuum at the time of commit (Mar 20, 2023)
$ echo "openapi: 3.0.1" | go run github.com/daveshanley/vacuum@v0.0.53 report -i -o | jq .resultSet
{
  "results": [
    ...
  ],
  "warningCount": 0,
  "errorCount": 2,
  "infoCount": 0
}

$ echo "broken-file" | go run github.com/daveshanley/vacuum@v0.0.53 report -i -o | jq .resultSet
{
  "results": null,
  "warningCount": 0,
  "errorCount": 0,
  "infoCount": 0
}

This is the latest version:

$ # Newer version of vacuum
$ echo "openapi: 3.0.1" | go run github.com/daveshanley/vacuum@latest report -i -o | jq .resultSet
{
  "results": [
    ...
  ],
  "warningCount": 1,
  "errorCount": 1,
  "infoCount": 0
}

$ echo "broken-file" | go run github.com/daveshanley/vacuum@latest report -i -o | jq .resultSet
{
  "warningCount": 0,
  "errorCount": 0,
  "infoCount": 0
}

As you can tell it was null back then but now the results key does not exist anymore. So this is the primary cause of the problem.

@coderabbitai

coderabbitai Bot commented Jan 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@iyxan23 iyxan23 changed the title Fix vacuum diagnostics crash on malformed file fix(builtins/diagnostics/vacuum): crash on malformed file Jan 14, 2026
@barrettruth

Copy link
Copy Markdown
Collaborator

wow. if only everyone documented their thought process this well...

@barrettruth
barrettruth merged commit e2cbdcb into nvimtools:main Jan 15, 2026
2 checks passed
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