Skip to content

fix(schema): always meta-validate generated schemas - #579

Merged
morluto merged 1 commit into
mainfrom
fix/remove-schema-trust-classifier
Aug 6, 2026
Merged

fix(schema): always meta-validate generated schemas#579
morluto merged 1 commit into
mainfrom
fix/remove-schema-trust-classifier

Conversation

@morluto

@morluto morluto commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Problem

PR #577 skipped Draft 2020-12 meta-schema validation for selected Pydantic-generated schemas. Its replacement trust classifier inspected __pydantic_core_schema__ metadata to distinguish default generation from custom output.

That is not a stable ownership boundary. Pydantic supports schema replacement and mutation through model methods, field extras, WithJsonSchema, nested types, custom core schemas, custom generators, and JSON-schema hooks. Tracking those internal representations recreates part of Pydantic's schema-generation machinery and can miss version-specific customization paths.

Change

  • remove the trusted validator and Pydantic core-schema trust classifier
  • route every register_model() result through the existing register() boundary
  • retain canonical-byte caching in _validated_schema, so each exact schema is meta-validated and compiled once per process
  • retain regressions proving malformed model overrides, field extras, and WithJsonSchema output are rejected before descriptor persistence

This follows python-jsonschema's documented boundary: validate the schema itself, construct the validator, then reuse that validator for payloads.

Validation

  • uv run --locked pytest -n 0 tests/component/schemas — 18 passed
  • focused Ruff and mypy checks — passed
  • exact diff review — no actionable findings

The runtime-construction performance concern remains valid, but should be addressed through initialization/publication/lazy-loading ownership rather than by weakening schema validation.

@cursor

cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@morluto
morluto merged commit 1c637a3 into main Aug 6, 2026
@morluto
morluto deleted the fix/remove-schema-trust-classifier branch August 6, 2026 17:53
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