fix(validator): close validation gaps and realign schema.json - #73
Merged
Conversation
The hand-written validator and res/schema.json had drifted since the
jsonschema dependency was dropped in v0.3.0.dev2. Fix four validation
gaps and regenerate the schema so both describe the same format.
- Empty entity {} now raises MissingKeyError instead of passing
validation and crashing the seeder with AttributeError
- Enforce a closed key set (check_keys) so unknown/typo keys raise
InvalidKeyError instead of being silently ignored
- Require exactly one source key; {data, filter} now raises instead
of silently picking data and ignoring filter
- Regenerate res/schema.json to match the validator: '!' relationship
prefix via patternProperties, additionalProperties:false, oneOf
source, parent/child model split (0 mismatches across 32 fixtures)
- Ship schema.json as package-data; document editor validation in README
- Remove now-unused MaxLengthExceededError
Advances #42.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Keep MaxLengthExceededError as a deprecated alias of InvalidKeyError so existing imports and except clauses keep working - Treat an empty parent dict as a valid no-op again (placeholder seed files); empty child dicts still raise MissingKeyError - Reject non-string attribute names with InvalidTypeError instead of leaking AttributeError from iter_ref_kwargs - Pin README schema URLs to a release tag instead of main - Drop dead PARENT_WITH_EXTRA_LENGTH_INVALID fixture and fix a wrong comment about the old 2-key budget Co-Authored-By: Claude Fable 5 <noreply@anthropic.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
The hand-written
validator.pyandres/schema.jsonhad been two independent, drifting definitions of "valid seed data" ever since thejsonschemadependency was dropped in v0.3.0.dev2 (the!relationship prefix landed in the same commit and broke the schema's object-vs-scalar assumption). This closes four validation gaps and regenerates the schema so both describe the exact same format. Advances #42.Validator fixes
{}— previously passed validation, then crashed the seeder with an opaqueAttributeError. Now raises a cleanMissingKeyError. (Thelen == 0early-return that skipped the model check is gone; empty lists are still a valid "seed nothing" no-op.)check_keys) — unknown/typo keys within the old 2-key budget were silently ignored. Now raiseInvalidKeyErrorwith a precise message. This also improves the basicSeeder's error for afilterkey from the misleading "Missing data key(s)" to "Unexpected key(s): filter".dataandfiltersilently useddata. Now raisesInvalidKeyError.data: {}vsdata: []— kept as-is by design ({}= one row of DB defaults,[]= zero rows). Documented rather than changed.Schema realignment
res/schema.jsonregenerated to mirror the fixed validator:!prefix viapatternProperties,additionalProperties: false(closed key set),oneOf(exactly one source), and aparent_entity/entitysplit encoding the parent-requires-model/ child-optional rule (the distinction the oldparent.jsononce needed a whole second file for).hybrid_validate.package-dataso the schema ships in the wheel (verified), and a README section on wiring it into editors (YAML modeline + VS Codejson.schemas/yaml.schemas).Cleanup
MaxLengthExceededError(not part of the public API / docs).Test plan
extra-key test to expect the more preciseInvalidKeyError.🤖 Generated with Claude Code