FastAPI 0.153.0 Extends Browser Form Handling to Unions of Pydantic Models

FastAPI·21 Oct 2026·2 min read

#fastapi

FastAPI has released version 0.153.0, a focused bug-fix update that brings consistency to how the framework parses browser form submissions. Previously, unions of Pydantic models did not receive the same browser-oriented form handling that individual models did, which could lead to inconsistent parsing behaviour depending on how a form endpoint's type annotation was structured. This release closes that gap. The change comes from PR #16540, credited to @tiangolo, and is scoped specifically to form-encoded requests — JSON request bodies are explicitly unchanged.

The concrete changes in this release:

  • Unions of form models now apply the same browser form handling as individual models, so parsing rules no longer differ based on whether the annotation is a single model or a union.
  • Empty scalar fields now either use their defaults or produce missing-field errors, matching the expected behaviour for browser-submitted forms.
  • Empty list items are preserved rather than silently dropped.
  • Omitted boolean fields are coerced to False, reflecting the way HTML checkboxes behave when unchecked.
  • Unselected files are treated as missing rather than being passed through as empty values.
  • JSON request bodies remain unaffected by all of the above.

For developers, the practical effect is predictability. HTML forms cannot express types the way JSON can: unchecked checkboxes send nothing, empty text inputs arrive as blank strings, and file inputs may submit no entry at all. FastAPI's browser form handling exists to translate those realities into sensible Python values, and this release ensures that translation works the same way inside a discriminated or informal union as it does with a plain model. If you annotate a form endpoint with a union of Pydantic models — a common pattern for multi-step or variant-dependent forms — you no longer need to normalise empty strings, missing booleans, or file fields yourself. Since JSON handling is untouched, upgrading should be low risk for API clients; focus testing on endpoints that accept Form data through unions.

Source: https://github.com/fastapi/fastapi/releases/tag/0.153.0

Related

auto-curated · source linked above← all news