FastAPI 0.140.9 is a patch release aimed at fixing a subtle bug in the jsonable_encoder utility and updating a few internal dependencies. The update ensures more predictable serialization behavior and keeps the project's toolchain up to date.
Concrete Changes
- Bug Fix:
exclude_defaultsnot propagated to dict keys and values injsonable_encoder. PR #16043 by @MBGrao.- Previously, when using
jsonable_encoderwithexclude_defaults=True, the setting was applied to top-level fields but not to nested dictionaries' keys and values. This fix ensures that default values are correctly excluded from all dict-like structures within the encoded output.
- Previously, when using
- Dependency Bumps:
gitpythonfrom 3.1.50 to 3.1.54: Addresses security and bug fixes in the Git library used internally by FastAPI's development tooling.pymdown-extensionsfrom 10.21.3 to 11.0: Major version bump with performance improvements and new features for Markdown rendering in documentation.pyasn1from 0.6.3 to 0.6.4: Minor update with fixes to ASN.1 library used indirectly through cryptography.
Why This Matters
The jsonable_encoder is a core utility in FastAPI for converting complex types (like Pydantic models, datetimes, etc.) into JSON-compatible types. The exclude_defaults parameter is commonly used to reduce payload size by omitting fields that have their default values. The bug meant that nested dict structures (e.g., a model with a dict field containing default values) would still include those defaults, leading to larger-than-expected payloads. This fix restores consistency and helps developers ship leaner APIs. Additionally, keeping dependencies updated reduces security risks and leverages performance improvements.
Source: https://github.com/fastapi/fastapi/releases/tag/0.140.9