Keep parse warnings when a schema is attached - #418
Open
holodorum wants to merge 1 commit into
Open
Conversation
`SchemaValidator.validate` discarded parse-phase warnings, such as duplicate keys, whenever the document had no hard errors: it returned the parse messages only on the error path, and otherwise built a fresh sink holding schema violations alone. Every consumer was affected: the LSP, the CLI's `--schema` check, and the Python, Rust, JS and Java bindings. It showed most in the editor, which relies solely on `validate` when a schema is attached, so schema-backed documents reported no warnings at all. `validate` now returns the parse messages followed by the schema violations. Parse errors still short-circuit, because an unparseable document cannot be checked against a schema. Every schema violation is a warning, so a CLI caller cannot tell one from a parse warning. The check is generalised rather than filtered: - `format`, `json` and `yaml` with `--schema` report every diagnostic on stderr and still produce output, failing only on parse errors or, with the new `--strict` flag, on any diagnostic. - Without `--schema` nothing changes unless `--strict` is given. - `validate` keeps failing on any message.
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.
Keep parse warnings when a schema is attached
SchemaValidator.validatediscarded parse-phase warnings, such as duplicate keys, whenever the document had no hard errors: it returned the parse messages only on the error path, and otherwise built a fresh sink holding schema violations alone.Every consumer was affected: the LSP, the CLI's
--schemacheck, and the Python, Rust, JS and Java bindings. It showed most in the editor, which relies solely onvalidatewhen a schema is attached, so schema-backed documents reported no warnings at all.The fix
validatenow returns the parse messages followed by the schema violations. Parse errors still short-circuit, because an unparseable document cannot be checked against a schema.CLI behaviour
Every schema violation is a warning, so a CLI caller cannot tell one from a parse warning. The check is generalised rather than filtered:
format,jsonandyamlwith--schemareport every diagnostic on stderr and still produce output, failing only on parse errors or, with the new--strictflag, on any diagnostic.--schemanothing changes unless--strictis given.validatekeeps failing on any message.Tests
Covered at the lib, LSP tooling and CLI layers. The VS Code test gives one document both a duplicate key and a missing required property, so a pass proves the schema was attached rather than the document having silently fallen back to the schema-less path, where parse warnings were never dropped.