FastAPI 0.150.0 Treats Empty Browser File Inputs as Missing

FastAPI·20 Oct 2026·2 min read

#fastapi

FastAPI has released 0.150.0, and the headline change affects how the framework interprets empty file uploads coming from browsers. When a user leaves a file input untouched, browsers still submit a file part — but with an empty filename and empty content. Previously this could be ambiguous for validation; the new release closes that gap by treating such parts as missing values rather than as uploaded files.

The change is documented as a breaking change, so it's worth reviewing if you depend on file-upload validation behaviour.

  • Unselected browser file inputs are now treated as missing rather than as empty files.
  • Required file fields now return a validation error when no file is selected, instead of accepting an empty upload.
  • Fields that define defaults or default factories now fall back to those defaults when the input is unselected.
  • Unselected inputs are ignored when files are supplied as a list, so empty parts no longer pollute the resulting collection.
  • Named zero-byte files are still accepted — only the browser's empty-filename placeholder is reclassified.

The work landed in PR #16534 by @tiangolo and is tagged as 0.150.0. No new commands or configuration flags are required; the behaviour is applied automatically.

For developers, this clarifies a long-standing edge case in form-based uploads. Instead of manually checking filename length or content size, you can rely on standard FastAPI validation: required File parameters fail fast with a clear error, optional parameters with defaults behave predictably, and list-based endpoints avoid spurious empty entries. If your frontend or tests depend on empty parts being accepted as zero-byte files, adjust them before upgrading — the practical rule now is that an unnamed empty part means "no file chosen," while a named empty file remains valid.

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

Related

auto-curated · source linked above← all news