The Wire · Showcase
Pydantic's JSON schema lies to you
By RepoJournal · Filed · About FastAPI & Pydantic
Pydantic is merging three PRs that fix silent mismatches between validation and generated JSON schemas, so clients stop approving data the model rejects.
Three Pydantic PRs [1][2][3] fix cases where the JSON schema does not reflect what the validator actually accepts. When you set `str_min_length` or `str_max_length` in config, the schema leaves out `minLength` and `maxLength`, so consumers accept input that later fails validation [1]. Likewise, serialization temporal formats like `ser_json_temporal='seconds'` leak into validation schemas, declaring a `number` where ISO date strings are expected [2]. And a docs update turns the Logfire integration page into a practical reference for capturing failed validations and connecting them to traces [4]. FastAPI gets an unglamorous but necessary fix: Typer's minimum is bumped to 0.26.1 to unstick failing CI tests under `lowest-direct` resolution [5]. With just 5 commits and 4 PRs across both repos, the stack is quiet, but these schema fixes are worth pulling into your next upgrade, especially if you expose JSON schema to clients. The Logfire docs now "turn the Logfire integration page into a practical setup reference," per the PR summary [4].
One email a day. Unsubscribe in one click.
Keep up with FastAPI & Pydantic in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.
One email a day. Unsubscribe in one click. Read a past issue →
Action items
- → Review your Pydantic-generated JSON schemas for missing minLength/maxLength constraints after upgrading pydantic/pydantic [plan]
- → Check validation schemas for accidental serialization formats when ser_json_temporal is set pydantic/pydantic [plan]
- → Monitor FastAPI dev for the Typer bump; it fixes CI but is not user-facing fastapi/fastapi [monitor]
References
- [1] Reflect `str_min_length` and `str_max_length` config in the JSON schema ↗ pydantic/pydantic
- [2] Don't apply serialization temporal formats to validation JSON schemas ↗ pydantic/pydantic
- [3] Reflect `str_min_length` and `str_max_length` config in the JSON schema (#13714) pydantic/pydantic
- [4] Improve Logfire guidance for validation errors ↗ pydantic/pydantic
- [5] ⬆️ Bump Typer min version to 0.26.1 ↗ fastapi/fastapi