Skip to content

spectral: Handle "no errors" output that produces invalid JSON#903

Merged
mfussenegger merged 1 commit intomfussenegger:masterfrom
V4G4X:fix/spectral_no_errors
Jan 31, 2026
Merged

spectral: Handle "no errors" output that produces invalid JSON#903
mfussenegger merged 1 commit intomfussenegger:masterfrom
V4G4X:fix/spectral_no_errors

Conversation

@V4G4X
Copy link
Contributor

@V4G4X V4G4X commented Jan 30, 2026

When spectral lint finds no errors, it outputs []No results with a severity of 'error' found! - concatenating valid JSON with a plain text message.

❯ spectral lint -f json Swagger.yaml                                                                              
[]No results with a severity of 'error' found!

This causes vim.json.decode() to fail.

Add a check for this specific message string before JSON parsing, returning an empty table to indicate no linting errors.

When spectral lint finds no errors, it outputs `[]No results with a
severity of 'error' found!` - concatenating valid JSON with a plain
text message. This causes vim.json.decode() to fail.

Add a check for this specific message string before JSON parsing,
returning an empty table to indicate no linting errors.
@mfussenegger
Copy link
Owner

mfussenegger commented Jan 31, 2026

Could this be due to the stream = "both", with No results with a severity of 'error' found! being reported on stderr and [] on stdout? Maybe stream ought to be changed to stdout instead.

@V4G4X
Copy link
Contributor Author

V4G4X commented Jan 31, 2026

Doesn't seem to be the case:

❯ spectral lint -f json Swagger.yaml 2>/dev/null
[]No results with a severity of 'error' found!

❯ spectral lint -f json Swagger.yaml 2>&1 1>/dev/null

2>/dev/null should have filtered out(deleted) any stderr part, but we have the whole thing, meaning it's all stdout.
2>&1 1>/dev/null should have filtered out(deleted) any stdout part, but have nothing, meaning it's all stdout.

@mfussenegger mfussenegger merged commit bcd1a44 into mfussenegger:master Jan 31, 2026
3 checks passed
@mfussenegger
Copy link
Owner

Thanks for double checking

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