Repository navigation
test(validation): pin schema-first reporting for malformed documents and announce skipped semantic checks - #271
Conversation
kayemkim
left a comment
There was a problem hiding this comment.
Picked this up since #270 still reproduces on main (831f48e): /dev/null, [], a bare scalar, and semantic_model: invalid all end in an AttributeError traceback. With the validate.py hunk from this PR applied on top of main, all four exit 1 with the [Schema] line and no traceback, the existing suites pass (uv run validation/test_validate.py and pytest on validation/tests/), and the 14 Ossie documents under examples/ and converters/**/tests produce byte-identical output before and after.
Two things before this can go in:
-
It no longer merges. Main gained its own
validation/test_validate.pyin #337 (a uv script that CI runs directly), so this PR's file is an add/add conflict, and it also points atcore-spec/osi-schema.json, which is nowossie-schema.json. The four cases would fit naturally as pytest functions invalidation/tests/test_validate.py, which CI already runs. -
if not errors and ...changes what a schema-invalid document reports. On main a document with one unknown property plus a duplicate dataset name and a dangling relationship target gets all three errors; with this change it gets only the schema one, and the other two show up on the next run. That is a defensible trade for never crashing, but it is a behaviour change worth stating in the PR, and maybe worth one line in the output ("semantic checks skipped until schema errors are fixed") so nobody is surprised. Gating on shape instead (root is a mapping,semantic_modelis a list of mappings) would keep today's behaviour for the common case, but the semantic checks would still need guards for deeper malformed values, so I can see why the simpler gate was chosen.
For ordering, #373 and #383 both edit the same part of main() (#383 changes the semantic_model gate itself), so whichever lands first, the others will need a small rebase.
flyrain
left a comment
There was a problem hiding this comment.
+1 Thanks @mattfaltyn. cc @khush-bhatia
b5b743b to
972e377
Compare
|
Thanks for the thorough review. Both points are addressed.
Rebased onto current
Agreed. The CLI now states when semantic checks are skipped, the behavior is documented in the PR description and Thanks again for the clear guidance. |
kayemkim
left a comment
There was a problem hiding this comment.
Re-ran the rebased head (972e377) merged into current main (fc6c9df): the validation-ci matrix (3.11 to 3.14) passes, the four #270 inputs (empty file, [], a bare scalar, semantic_model: invalid) exit 1 with a [Schema] line and the new notice instead of a traceback, and the 14 Ossie documents under examples/ and converters/** keep their exit codes, the only output change being the notice on the three ontology files that already fail the core schema. The tests in validation/tests/, the notice, and the docs/index.md line cover both points I raised. LGTM.
One ordering note: #383 (approved yesterday) adds the same not errors and isinstance(data, dict) gate on its own, and with that branch alone the four inputs also stop crashing. If it lands first, this conflicts in both files and reduces to the notice, the docs line, and the tests, which #383 does not have for malformed shapes. The test_schema_errors_defer_semantic_errors fixture would then need the flat shape (datasets: at the root); otherwise the wrapper itself trips the schema and the duplicate-name and dangling-target parts of the case are no longer exercised.
972e377 to
b545635
Compare
Done, thank you. I rebased onto current |
Signed-off-by: Matt Faltyn <faltyn.matthew@gmail.com>
b545635 to
6234c33
Compare
kayemkim
left a comment
There was a problem hiding this comment.
Since the rebase this sits on #383, which already stops the four #270 inputs at the [Schema] line on main, so what the PR adds now is the skipped-checks notice, the tests for the malformed shapes, the docs line and the object annotation. The title and summary still describe the fix #383 landed, and the title becomes the squash commit. Something like test(validation): pin schema-first reporting for malformed documents and announce skipped semantic checks would match what is left; with that I am glad to approve and merge.
Summary
#383 already prevents malformed documents from reaching semantic checks on
main. This PR builds on that behavior by pinning schema-first reporting and explaining when semantic checks are skipped.docs/index.md.validate_schemainput asobjectto reflect the values it validates.Behavior
Schema-invalid documents continue to exit 1 with their schema errors. The new notice explains that semantic checks were skipped until those errors are fixed. A subsequent run can then report any remaining semantic errors.
The specification, CLI arguments, and dependency set are unchanged.
Related context
Related to #270. The crash prevention and schema-first gate are already present on
mainthrough #383; this PR adds reporting, regression coverage, documentation, and the input annotation.Validation
All Validation CI commands pass locally on Python 3.13.13:
Results: 59 unittest tests, 495 validation pytest tests, and 268 shared Python model tests passed. Schema synchronization, all example validations, compilation, and diff checks passed. The mapping example emitted two non-fatal SQL-expression warnings.
Checklist