FastAPI 0.148.0 reworks how defaults are handled for request parameters and models, and it ships as a breaking change. The core shift: defaults for omitted Query, Header, Cookie and Form parameters — as well as model fields — are no longer treated as user input. As a result, those defaults are not validated unless default validation is explicitly turned on.
- If you rely on validators running for omitted values, enable default validation with
Field(validate_default=True)for model fields, orQuery(validate_default=True)(and the equivalents) for individual parameters. Body(validate_default=True)is now honored as well.- For parameter models, applying a default no longer marks a field as explicitly set, so
model_dump(exclude_unset=True)excludes it. - Default factories run once, and validation errors no longer include injected defaults in the
inputpayload. - Omitted boolean form fields still become
Falseand count as explicitly set.
The change comes from PR #16527 by @tiangolo, titled "Fix default handling for request parameters and models," and is flagged under Breaking Changes.
For developers, the practical impact depends on how much you lean on validators. Pydantic validators that previously ran against default values on omitted inputs will silently stop firing unless you opt in with validate_default=True. That can affect coercion logic, normalisation steps and custom constraints encoded in validators. The exclude_unset=True behavior is also worth auditing if you forward serialized models to downstream systems that distinguish explicit values from defaults. Review request models and parameter declarations before upgrading, and add explicit default validation only where the previous behavior was intentional.
Source: https://github.com/fastapi/fastapi/releases/tag/0.148.0