fix(validation): reject duplicate mapping keys - #337
Open
iamrajatrana wants to merge 2 commits into
Open
Conversation
Signed-off-by: iamrajatrana <rjtrana16@gmail.com>
Signed-off-by: iamrajatrana <rjtrana16@gmail.com>
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.
Summary
Reject duplicate keys in YAML and JSON mappings before schema validation can run against silently overwritten data. The loader remains derived from
yaml.SafeLoader, adds no dependency, preserves aliases and legal merge-key overrides, and reports both mapping and duplicate-key source locations.This PR also adds Validation CI so the validator tests and canonical example run on Python 3.11 through 3.14 whenever validation, core specification, or canonical example files change.
Before
After
Edge cases covered
"<<"keyMerge-key behavior
A mapping may contain one YAML merge key and explicitly override values inherited through that merge; this remains supported. Repeating the special
<<merge key in the same mapping is rejected because YAML provides the sequence form (<<: [*first, *second]) for merging multiple mappings and mapping keys are expected to be unique.Scope notes
validation/validate.py. Several converters load their own vendor-specific YAML withyaml.safe_load; applying a shared strict-loading policy across those independent packages requires separate compatibility evaluation.data.get(...)assumption and raiseAttributeError. That behavior is unrelated to duplicate-key detection and is not changed here.uv run validation/test_validate.py, matching their PEP 723 dependency metadata and script-local import path.Related Issues
Closes #336
Tests
uv run validation/test_validate.py(16 tests)uv run validation/validate.py examples/tpcds_semantic_model.yamluv run --with ruff ruff check --ignore EXE001 validation/validate.py validation/test_validate.pyChecklist