Nested Schema Validation & Type mismatch check#729
Open
AbhinRustagi wants to merge 29 commits into
Open
Conversation
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.
What this PR does
Previously the parser only checked that required top-level props were present — nested data was never validated, and a wrong-typed value flowed straight to the renderer. This PR adds recursive JSON-Schema validation of all component props (objects, arrays, scalar/enum leaves, and component elements in data positions), and applies one consistent resolution rule to every invalid value instead of either ignoring it or blanking the UI:
At the outermost edge (component param), "propagate" means drop the component. Net effect: a deep violation can only blank the root if every edge on the path is required and none is an array item — i.e. only when the tree genuinely cannot satisfy the schema. LLM output degrades gracefully; the error always reaches the host's
onErrorfor the correction loop.Cases covered
missing-required/null-required) + parent invalidtype-mismatch→ resolution ruletype-mismatch→ resolution ruleHorizontalBarChart(Card([]), …))type-mismatch("expects array but got component Card") → resolution rule$ref/anyOf)Badge("primcut mid-token)$ref/anyOf/oneOf/allOf) for plain values$var, builtins)type, tupleitems, non-arrayrequired)defaultvalues themselvesDeferred (explicit non-goals here)
$refresolution — data behind$ref(e.g. chartSeries) is still unchecked; biggest coverage gap, planned next.partial(checks currently gate on whole-document completeness);additionalProperties; constraint keywords (minItems,pattern, …).