Skip to content

Fix ValidationInfo.data missing with model_validate_json()#13079

Merged
davidhewitt merged 3 commits intomainfrom
dh/validate-by-json-val-info
Apr 15, 2026
Merged

Fix ValidationInfo.data missing with model_validate_json()#13079
davidhewitt merged 3 commits intomainfrom
dh/validate-by-json-val-info

Conversation

@davidhewitt
Copy link
Copy Markdown
Collaborator

Change Summary

This PR fixes ValidationInfo.data missing when using model_validate_json. This is done by delaying validation of input JSON values until the JSON document has been full parsed; the validations can then be carried out in field order.

Related issue number

Fixes #13074

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 15, 2026

@davidhewitt davidhewitt requested a review from Viicos April 15, 2026 11:10
@Viicos Viicos changed the title Fix ValidationInfo data missing with model_validate_json Fix ValidationInfo.data missing with model_validate_json() Apr 15, 2026
Comment thread tests/types/test_model.py Outdated
@Viicos Viicos added relnotes-fix Used for bugfixes. backport-2.13 Needs backport to 2.13 labels Apr 15, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 15, 2026

Merging this PR will degrade performance by 18.75%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 213 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
test_failed_rebuild 244.2 µs 300.5 µs -18.75%
test_simple_recursive_model_schema_generation 839.9 µs 620.1 µs +35.45%

Comparing dh/validate-by-json-val-info (67ac6fd) with main (71f0c4b)

Open in CodSpeed

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 15, 2026

Coverage report

This PR does not seem to contain any modification to coverable code.

@davidhewitt davidhewitt enabled auto-merge (squash) April 15, 2026 13:31
@davidhewitt davidhewitt merged commit b7e81cf into main Apr 15, 2026
76 of 77 checks passed
@davidhewitt davidhewitt deleted the dh/validate-by-json-val-info branch April 15, 2026 13:44
Viicos added a commit that referenced this pull request Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-2.13 Needs backport to 2.13 relnotes-fix Used for bugfixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing ValidationInfo data using model_validate_json with v2.13.0

2 participants