Skip to content

fix: enforce Pydantic constraints on every validation path (review HIGH)#97

Open
sorenwacker wants to merge 4 commits into
mainfrom
fix-validation-false-negatives
Open

fix: enforce Pydantic constraints on every validation path (review HIGH)#97
sorenwacker wants to merge 4 commits into
mainfrom
fix-validation-false-negatives

Conversation

@sorenwacker

Copy link
Copy Markdown
Owner

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 while validate_entity() caught them. Extracted a shared _pydantic_constraint_errors helper now run on all paths:

  • validate() cascade + non-cascade
  • validate_entity() (refactored to the helper, DRY)
  • DatasetValidator file/directory path (was also engine-only)

Also: validate_instance (MCP validate_extracted) treated a required field set to null as 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 by IdRegistry.
  • ontology.py non-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

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant