Skip to content

Keep parse warnings when a schema is attached - #418

Open
holodorum wants to merge 1 commit into
kson-org:mainfrom
holodorum:fix/kson-diagnostic-bug
Open

Keep parse warnings when a schema is attached#418
holodorum wants to merge 1 commit into
kson-org:mainfrom
holodorum:fix/kson-diagnostic-bug

Conversation

@holodorum

Copy link
Copy Markdown
Collaborator

Keep parse warnings when a schema is attached

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.

The fix

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.

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, 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.

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.

`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.
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.

1 participant