fix: enforce Pydantic constraints on every validation path (review HIGH)#97
Open
sorenwacker wants to merge 4 commits into
Open
fix: enforce Pydantic constraints on every validation path (review HIGH)#97sorenwacker wants to merge 4 commits into
sorenwacker wants to merge 4 commits into
Conversation
validate() (the REST/CLI path) and its cascade ran only the rule engine, which does not implement pattern/range/length/enum constraints, so violations were silently reported valid while validate_entity() caught them. Extract the Pydantic constraint check into a shared _pydantic_constraint_errors helper and run it on all three paths (validate cascade + non-cascade, validate_entity).
The MCP extraction validation path (validate_extracted -> validate_instance) only checked for an absent key, so a required field explicitly set to null was reported valid. Flag present-but-null the same as missing.
DatasetValidator.validate_file/validate_directory ran only the rule engine per node, skipping the pattern/range/length/enum constraints the single-entity path checks. Run the shared _pydantic_constraint_errors per node so file/directory validation catches the same violations.
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.
Fixes the review's HIGH finding and the related false-negative-validation theme (#18), plus lands docs/REVIEW.md.
The HIGH:
validate()(the REST/CLI path) and its cascade ran only the rule engine, which doesn't implement pattern/range/length/enum constraints — so violations were silently reported valid whilevalidate_entity()caught them. Extracted a shared_pydantic_constraint_errorshelper now run on all paths:validate()cascade + non-cascadevalidate_entity()(refactored to the helper, DRY)DatasetValidatorfile/directory path (was also engine-only)Also:
validate_instance(MCPvalidate_extracted) treated a required field set tonullas valid — now flagged like a missing key.Two review items reclassified during the fix:
UniquenessRule"no-op" is a false positive — it's intentional/documented, and dataset-wide uniqueness is enforced byIdRegistry.ontology.pynon-OBO is a false positive (a valid non-OBO term is over-rejected), not a false negative; deferred to Support for export of PRIDE submission file #21 (needs OLS lookup-by-id + network mocking).5 new regression tests; 1706 pass; ruff/mypy green.
docs/REVIEW.md(full-codebase review) included.🤖 Generated with Claude Code