Fastapi

Latest version: v0.115.8

Safety actively analyzes 706267 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 6 of 34

0.106.0

Not secure
Breaking Changes

Using resources from dependencies with `yield` in background tasks is no longer supported.

This change is what supports the new features, read below. 🤓

Dependencies with `yield`, `HTTPException` and Background Tasks

Dependencies with `yield` now can raise `HTTPException` and other exceptions after `yield`. 🎉

Read the new docs here: [Dependencies with `yield` and `HTTPException`](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/#dependencies-with-yield-and-httpexception).

Python
from fastapi import Depends, FastAPI, HTTPException
from typing_extensions import Annotated

app = FastAPI()


data = {
"plumbus": {"description": "Freshly pickled plumbus", "owner": "Morty"},
"portal-gun": {"description": "Gun to create portals", "owner": "Rick"},
}


class OwnerError(Exception):
pass


def get_username():
try:
yield "Rick"
except OwnerError as e:
raise HTTPException(status_code=400, detail=f"Onwer error: {e}")


app.get("/items/{item_id}")
def get_item(item_id: str, username: Annotated[str, Depends(get_username)]):
if item_id not in data:
raise HTTPException(status_code=404, detail="Item not found")
item = data[item_id]
if item["owner"] != username:
raise OwnerError(username)
return item


---

Before FastAPI 0.106.0, raising exceptions after `yield` was not possible, the exit code in dependencies with `yield` was executed *after* the response was sent, so [Exception Handlers](https://fastapi.tiangolo.com/tutorial/handling-errors/#install-custom-exception-handlers) would have already run.

This was designed this way mainly to allow using the same objects "yielded" by dependencies inside of background tasks, because the exit code would be executed after the background tasks were finished.

Nevertheless, as this would mean waiting for the response to travel through the network while unnecessarily holding a resource in a dependency with yield (for example a database connection), this was changed in FastAPI 0.106.0.

Additionally, a background task is normally an independent set of logic that should be handled separately, with its own resources (e.g. its own database connection).

If you used to rely on this behavior, now you should create the resources for background tasks inside the background task itself, and use internally only data that doesn't depend on the resources of dependencies with `yield`.

For example, instead of using the same database session, you would create a new database session inside of the background task, and you would obtain the objects from the database using this new session. And then instead of passing the object from the database as a parameter to the background task function, you would pass the ID of that object and then obtain the object again inside the background task function.

The sequence of execution before FastAPI 0.106.0 was like the diagram in the [Release Notes for FastAPI 0.106.0](https://fastapi.tiangolo.com/release-notes/#01060).

The new execution flow can be found in the docs: [Execution of dependencies with `yield`](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/#execution-of-dependencies-with-yield).

0.105.0

Not secure
Features

* ✨ Add support for multiple Annotated annotations, e.g. `Annotated[str, Field(), Query()]`. PR [10773](https://github.com/tiangolo/fastapi/pull/10773) by [tiangolo](https://github.com/tiangolo).

Refactors

* 🔥 Remove unused NoneType. PR [10774](https://github.com/tiangolo/fastapi/pull/10774) by [tiangolo](https://github.com/tiangolo).

Docs

* 📝 Tweak default suggested configs for generating clients. PR [10736](https://github.com/tiangolo/fastapi/pull/10736) by [tiangolo](https://github.com/tiangolo).

Internal

* 🔧 Update sponsors, add Scalar. PR [10728](https://github.com/tiangolo/fastapi/pull/10728) by [tiangolo](https://github.com/tiangolo).
* 🔧 Update sponsors, add PropelAuth. PR [10760](https://github.com/tiangolo/fastapi/pull/10760) by [tiangolo](https://github.com/tiangolo).
* 👷 Update build docs, verify README on CI. PR [10750](https://github.com/tiangolo/fastapi/pull/10750) by [tiangolo](https://github.com/tiangolo).
* 🔧 Update sponsors, remove Fern. PR [10729](https://github.com/tiangolo/fastapi/pull/10729) by [tiangolo](https://github.com/tiangolo).
* 🔧 Update sponsors, add Codacy. PR [10677](https://github.com/tiangolo/fastapi/pull/10677) by [tiangolo](https://github.com/tiangolo).
* 🔧 Update sponsors, add Reflex. PR [10676](https://github.com/tiangolo/fastapi/pull/10676) by [tiangolo](https://github.com/tiangolo).
* 📝 Update release notes, move and check latest-changes. PR [10588](https://github.com/tiangolo/fastapi/pull/10588) by [tiangolo](https://github.com/tiangolo).
* 👷 Upgrade latest-changes GitHub Action. PR [10587](https://github.com/tiangolo/fastapi/pull/10587) by [tiangolo](https://github.com/tiangolo).

0.104.1

Not secure
Fixes

* 📌 Pin Swagger UI version to 5.9.0 temporarily to handle a bug crashing it in 5.9.1. PR [10529](https://github.com/tiangolo/fastapi/pull/10529) by [alejandraklachquin](https://github.com/alejandraklachquin).
* This is not really a bug in FastAPI but in Swagger UI, nevertheless pinning the version will work while a solution is found on the [Swagger UI side](https://github.com/swagger-api/swagger-ui/issues/9337).

Docs

* 📝 Update data structure and render for external-links. PR [10495](https://github.com/tiangolo/fastapi/pull/10495) by [tiangolo](https://github.com/tiangolo).
* ✏️ Fix link to SPDX license identifier in `docs/en/docs/tutorial/metadata.md`. PR [10433](https://github.com/tiangolo/fastapi/pull/10433) by [worldworm](https://github.com/worldworm).
* 📝 Update example validation error from Pydantic v1 to match Pydantic v2 in `docs/en/docs/tutorial/path-params.md`. PR [10043](https://github.com/tiangolo/fastapi/pull/10043) by [giuliowaitforitdavide](https://github.com/giuliowaitforitdavide).
* ✏️ Fix typos in emoji docs and in some source examples. PR [10438](https://github.com/tiangolo/fastapi/pull/10438) by [afuetterer](https://github.com/afuetterer).
* ✏️ Fix typo in `docs/en/docs/reference/dependencies.md`. PR [10465](https://github.com/tiangolo/fastapi/pull/10465) by [suravshresth](https://github.com/suravshresth).
* ✏️ Fix typos and rewordings in `docs/en/docs/tutorial/body-nested-models.md`. PR [10468](https://github.com/tiangolo/fastapi/pull/10468) by [yogabonito](https://github.com/yogabonito).
* 📝 Update docs, remove references to removed `pydantic.Required` in `docs/en/docs/tutorial/query-params-str-validations.md`. PR [10469](https://github.com/tiangolo/fastapi/pull/10469) by [yogabonito](https://github.com/yogabonito).
* ✏️ Fix typo in `docs/en/docs/reference/index.md`. PR [10467](https://github.com/tiangolo/fastapi/pull/10467) by [tarsil](https://github.com/tarsil).
* 🔥 Remove unnecessary duplicated docstrings. PR [10484](https://github.com/tiangolo/fastapi/pull/10484) by [tiangolo](https://github.com/tiangolo).

Internal

* ✏️ Update Pydantic links to dotenv support. PR [10511](https://github.com/tiangolo/fastapi/pull/10511) by [White-Mask](https://github.com/White-Mask).
* ✏️ Update links in `docs/en/docs/async.md` and `docs/zh/docs/async.md` to make them relative. PR [10498](https://github.com/tiangolo/fastapi/pull/10498) by [hasnatsajid](https://github.com/hasnatsajid).
* ✏️ Fix links in `docs/em/docs/async.md`. PR [10507](https://github.com/tiangolo/fastapi/pull/10507) by [hasnatsajid](https://github.com/hasnatsajid).
* ✏️ Fix typo in `docs/em/docs/index.md`, Python 3.8. PR [10521](https://github.com/tiangolo/fastapi/pull/10521) by [kerriop](https://github.com/kerriop).
* ⬆ Bump pillow from 9.5.0 to 10.1.0. PR [10446](https://github.com/tiangolo/fastapi/pull/10446) by [dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Update mkdocs-material requirement from <9.0.0,>=8.1.4 to >=8.1.4,<10.0.0. PR [5862](https://github.com/tiangolo/fastapi/pull/5862) by [dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump mkdocs-material from 9.1.21 to 9.4.7. PR [10545](https://github.com/tiangolo/fastapi/pull/10545) by [dependabot[bot]](https://github.com/apps/dependabot).
* 👷 Install MkDocs Material Insiders only when secrets are available, for Dependabot. PR [10544](https://github.com/tiangolo/fastapi/pull/10544) by [tiangolo](https://github.com/tiangolo).
* 🔧 Update sponsors badges, Databento. PR [10519](https://github.com/tiangolo/fastapi/pull/10519) by [tiangolo](https://github.com/tiangolo).
* 👷 Adopt Ruff format. PR [10517](https://github.com/tiangolo/fastapi/pull/10517) by [tiangolo](https://github.com/tiangolo).
* 🔧 Add `CITATION.cff` file for academic citations. PR [10496](https://github.com/tiangolo/fastapi/pull/10496) by [tiangolo](https://github.com/tiangolo).
* 🐛 Fix overriding MKDocs theme lang in hook. PR [10490](https://github.com/tiangolo/fastapi/pull/10490) by [tiangolo](https://github.com/tiangolo).
* 🔥 Drop/close Gitter chat. Questions should go to GitHub Discussions, free conversations to Discord.. PR [10485](https://github.com/tiangolo/fastapi/pull/10485) by [tiangolo](https://github.com/tiangolo).

0.104.0

Not secure
Features

* ✨ Add reference (code API) docs with PEP 727, add subclass with custom docstrings for `BackgroundTasks`, refactor docs structure. PR [10392](https://github.com/tiangolo/fastapi/pull/10392) by [tiangolo](https://github.com/tiangolo). New docs at [FastAPI Reference - Code API](https://fastapi.tiangolo.com/reference/).

Upgrades

* ⬆️ Drop support for Python 3.7, require Python 3.8 or above. PR [10442](https://github.com/tiangolo/fastapi/pull/10442) by [tiangolo](https://github.com/tiangolo).

Internal

* ⬆ Bump dawidd6/action-download-artifact from 2.27.0 to 2.28.0. PR [10268](https://github.com/tiangolo/fastapi/pull/10268) by [dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump actions/checkout from 3 to 4. PR [10208](https://github.com/tiangolo/fastapi/pull/10208) by [dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump pypa/gh-action-pypi-publish from 1.8.6 to 1.8.10. PR [10061](https://github.com/tiangolo/fastapi/pull/10061) by [dependabot[bot]](https://github.com/apps/dependabot).
* 🔧 Update sponsors, Bump.sh images. PR [10381](https://github.com/tiangolo/fastapi/pull/10381) by [tiangolo](https://github.com/tiangolo).
* 👥 Update FastAPI People. PR [10363](https://github.com/tiangolo/fastapi/pull/10363) by [tiangolo](https://github.com/tiangolo).

0.103.2

Not secure
Refactors

* ⬆️ Upgrade compatibility with Pydantic v2.4, new renamed functions and JSON Schema input/output models with default values. PR [10344](https://github.com/tiangolo/fastapi/pull/10344) by [tiangolo](https://github.com/tiangolo).

Translations

* 🌐 Add Ukrainian translation for `docs/uk/docs/tutorial/extra-data-types.md`. PR [10132](https://github.com/tiangolo/fastapi/pull/10132) by [ArtemKhymenko](https://github.com/ArtemKhymenko).
* 🌐 Fix typos in French translations for `docs/fr/docs/advanced/path-operation-advanced-configuration.md`, `docs/fr/docs/alternatives.md`, `docs/fr/docs/async.md`, `docs/fr/docs/features.md`, `docs/fr/docs/help-fastapi.md`, `docs/fr/docs/index.md`, `docs/fr/docs/python-types.md`, `docs/fr/docs/tutorial/body.md`, `docs/fr/docs/tutorial/first-steps.md`, `docs/fr/docs/tutorial/query-params.md`. PR [10154](https://github.com/tiangolo/fastapi/pull/10154) by [s-rigaud](https://github.com/s-rigaud).
* 🌐 Add Chinese translation for `docs/zh/docs/async.md`. PR [5591](https://github.com/tiangolo/fastapi/pull/5591) by [mkdir700](https://github.com/mkdir700).
* 🌐 Update Chinese translation for `docs/tutorial/security/simple-oauth2.md`. PR [3844](https://github.com/tiangolo/fastapi/pull/3844) by [jaystone776](https://github.com/jaystone776).
* 🌐 Add Korean translation for `docs/ko/docs/deployment/cloud.md`. PR [10191](https://github.com/tiangolo/fastapi/pull/10191) by [Sion99](https://github.com/Sion99).
* 🌐 Add Japanese translation for `docs/ja/docs/deployment/https.md`. PR [10298](https://github.com/tiangolo/fastapi/pull/10298) by [tamtam-fitness](https://github.com/tamtam-fitness).
* 🌐 Fix typo in Russian translation for `docs/ru/docs/tutorial/body-fields.md`. PR [10224](https://github.com/tiangolo/fastapi/pull/10224) by [AlertRED](https://github.com/AlertRED).
* 🌐 Add Polish translation for `docs/pl/docs/help-fastapi.md`. PR [10121](https://github.com/tiangolo/fastapi/pull/10121) by [romabozhanovgithub](https://github.com/romabozhanovgithub).
* 🌐 Add Russian translation for `docs/ru/docs/tutorial/header-params.md`. PR [10226](https://github.com/tiangolo/fastapi/pull/10226) by [AlertRED](https://github.com/AlertRED).
* 🌐 Add Chinese translation for `docs/zh/docs/deployment/versions.md`. PR [10276](https://github.com/tiangolo/fastapi/pull/10276) by [xzmeng](https://github.com/xzmeng).

Internal

* 🔧 Update sponsors, remove Flint. PR [10349](https://github.com/tiangolo/fastapi/pull/10349) by [tiangolo](https://github.com/tiangolo).
* 🔧 Rename label "awaiting review" to "awaiting-review" to simplify search queries. PR [10343](https://github.com/tiangolo/fastapi/pull/10343) by [tiangolo](https://github.com/tiangolo).
* 🔧 Update sponsors, enable Svix (revert 10228). PR [10253](https://github.com/tiangolo/fastapi/pull/10253) by [tiangolo](https://github.com/tiangolo).
* 🔧 Update sponsors, remove Svix. PR [10228](https://github.com/tiangolo/fastapi/pull/10228) by [tiangolo](https://github.com/tiangolo).
* 🔧 Update sponsors, add Bump.sh. PR [10227](https://github.com/tiangolo/fastapi/pull/10227) by [tiangolo](https://github.com/tiangolo).

0.103.1

Not secure
Fixes

* 📌 Pin AnyIO to < 4.0.0 to handle an incompatibility while upgrading to Starlette 0.31.1. PR [10194](https://github.com/tiangolo/fastapi/pull/10194) by [tiangolo](https://github.com/tiangolo).

Docs

* ✏️ Fix validation parameter name in docs, from `regex` to `pattern`. PR [10085](https://github.com/tiangolo/fastapi/pull/10085) by [pablodorrio](https://github.com/pablodorrio).
* ✏️ Fix indent format in `docs/en/docs/deployment/server-workers.md`. PR [10066](https://github.com/tiangolo/fastapi/pull/10066) by [tamtam-fitness](https://github.com/tamtam-fitness).
* ✏️ Fix Pydantic examples in tutorial for Python types. PR [9961](https://github.com/tiangolo/fastapi/pull/9961) by [rahulsalgare](https://github.com/rahulsalgare).
* ✏️ Fix link to Pydantic docs in `docs/en/docs/tutorial/extra-data-types.md`. PR [10155](https://github.com/tiangolo/fastapi/pull/10155) by [hasnatsajid](https://github.com/hasnatsajid).
* ✏️ Fix typo in `docs/en/docs/tutorial/handling-errors.md`. PR [10170](https://github.com/tiangolo/fastapi/pull/10170) by [poupapaa](https://github.com/poupapaa).
* ✏️ Fix typo in `docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md`. PR [10172](https://github.com/tiangolo/fastapi/pull/10172) by [ragul-kachiappan](https://github.com/ragul-kachiappan).

Translations

* 🌐 Remove duplicate line in translation for `docs/pt/docs/tutorial/path-params.md`. PR [10126](https://github.com/tiangolo/fastapi/pull/10126) by [LecoOliveira](https://github.com/LecoOliveira).
* 🌐 Add Yoruba translation for `docs/yo/docs/index.md`. PR [10033](https://github.com/tiangolo/fastapi/pull/10033) by [AfolabiOlaoluwa](https://github.com/AfolabiOlaoluwa).
* 🌐 Add Ukrainian translation for `docs/uk/docs/python-types.md`. PR [10080](https://github.com/tiangolo/fastapi/pull/10080) by [rostik1410](https://github.com/rostik1410).
* 🌐 Add Vietnamese translations for `docs/vi/docs/tutorial/first-steps.md` and `docs/vi/docs/tutorial/index.md`. PR [10088](https://github.com/tiangolo/fastapi/pull/10088) by [magiskboy](https://github.com/magiskboy).
* 🌐 Add Ukrainian translation for `docs/uk/docs/alternatives.md`. PR [10060](https://github.com/tiangolo/fastapi/pull/10060) by [whysage](https://github.com/whysage).
* 🌐 Add Ukrainian translation for `docs/uk/docs/tutorial/index.md`. PR [10079](https://github.com/tiangolo/fastapi/pull/10079) by [rostik1410](https://github.com/rostik1410).
* ✏️ Fix typos in `docs/en/docs/how-to/separate-openapi-schemas.md` and `docs/en/docs/tutorial/schema-extra-example.md`. PR [10189](https://github.com/tiangolo/fastapi/pull/10189) by [xzmeng](https://github.com/xzmeng).
* 🌐 Add Chinese translation for `docs/zh/docs/advanced/generate-clients.md`. PR [9883](https://github.com/tiangolo/fastapi/pull/9883) by [funny-cat-happy](https://github.com/funny-cat-happy).

Refactors

* ✏️ Fix typos in comment in `fastapi/applications.py`. PR [10045](https://github.com/tiangolo/fastapi/pull/10045) by [AhsanSheraz](https://github.com/AhsanSheraz).
* ✅ Add missing test for OpenAPI examples, it was missing in coverage. PR [10188](https://github.com/tiangolo/fastapi/pull/10188) by [tiangolo](https://github.com/tiangolo).

Internal

* 👥 Update FastAPI People. PR [10186](https://github.com/tiangolo/fastapi/pull/10186) by [tiangolo](https://github.com/tiangolo).

Page 6 of 34

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.