Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency fastapi to v0.110.0 #38

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Aug 25, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
fastapi ==0.101.1 -> ==0.110.0 age adoption passing confidence

Release Notes

tiangolo/fastapi (fastapi)

v0.110.0

Compare Source

Breaking Changes
  • 🐛 Fix unhandled growing memory for internal server errors, refactor dependencies with yield and except to require raising again as in regular Python. PR #​11191 by @​tiangolo.
    • This is a breaking change (and only slightly) if you used dependencies with yield, used except in those dependencies, and didn't raise again.
    • This was reported internally by @​rushilsrivastava as a memory leak when the server had unhandled exceptions that would produce internal server errors, the memory allocated before that point would not be released.
    • Read the new docs: Dependencies with yield and except.

In short, if you had dependencies that looked like:

def my_dep():
    try:
        yield
    except SomeException:
        pass

Now you need to make sure you raise again after except, just as you would in regular Python:

def my_dep():
    try:
        yield
    except SomeException:
        raise
Docs
Translations

v0.109.2

Compare Source

Upgrades
Translations
Internal

v0.109.1

Compare Source

Security fixes
  • ⬆️ Upgrade minimum version of python-multipart to >=0.0.7 to fix a vulnerability when using form data with a ReDos attack. You can also simply upgrade python-multipart.

Read more in the advisory: Content-Type Header ReDoS.

Features
Refactors
  • ✅ Refactor tests for duplicate operation ID generation for compatibility with other tools running the FastAPI test suite. PR #​10876 by @​emmettbutler.
  • ♻️ Simplify string format with f-strings in fastapi/utils.py. PR #​10576 by @​eukub.
  • 🔧 Fix Ruff configuration unintentionally enabling and re-disabling mccabe complexity check. PR #​10893 by @​jiridanek.
  • ✅ Re-enable test in tests/test_tutorial/test_header_params/test_tutorial003.py after fix in Starlette. PR #​10904 by @​ooknimm.
Docs
Translations
Internal

v0.109.0

Compare Source

Features
Upgrades
Docs
Translations
Internal

v0.108.0

Compare Source

Upgrades
  • ⬆️ Upgrade Starlette to >=0.29.0,<0.33.0, update docs and usage of templates with new Starlette arguments. PR #​10846 by @​tiangolo.

v0.107.0

Compare Source

Upgrades
Docs

v0.106.0

Compare Source

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.

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}")

@&#8203;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 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.

The new execution flow can be found in the docs: Execution of dependencies with yield.

v0.105.0

Compare Source

Features
  • ✨ Add support for multiple Annotated annotations, e.g. Annotated[str, Field(), Query()]. PR #​10773 by @​tiangolo.
Refactors
Docs
Internal

v0.104.1

Compare Source

Fixes
  • 📌 Pin Swagger UI version to 5.9.0 temporarily to handle a bug crashing it in 5.9.1. PR #​10529 by @​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.
Docs
Internal

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot changed the title chore(deps): update dependency fastapi to v0.102.0 chore(deps): update dependency fastapi to v0.103.0 Aug 26, 2023
@renovate renovate bot force-pushed the renovate/fastapi-0.x branch 7 times, most recently from 7b67aac to 2f4861c Compare September 1, 2023 16:27
@renovate renovate bot changed the title chore(deps): update dependency fastapi to v0.103.0 chore(deps): update dependency fastapi to v0.103.1 Sep 2, 2023
@renovate renovate bot force-pushed the renovate/fastapi-0.x branch 2 times, most recently from 7d62ce3 to 2075be2 Compare September 9, 2023 12:40
@renovate renovate bot force-pushed the renovate/fastapi-0.x branch 3 times, most recently from 6b2ebf3 to 8940214 Compare September 13, 2023 11:38
@renovate renovate bot changed the title chore(deps): update dependency fastapi to v0.103.1 chore(deps): update dependency fastapi to v0.103.2 Sep 28, 2023
@renovate renovate bot force-pushed the renovate/fastapi-0.x branch 2 times, most recently from ae1b4d8 to 129ebda Compare October 13, 2023 22:25
@renovate renovate bot changed the title chore(deps): update dependency fastapi to v0.103.2 chore(deps): update dependency fastapi to v0.104.0 Oct 18, 2023
@renovate renovate bot force-pushed the renovate/fastapi-0.x branch 2 times, most recently from cf1754a to 938639d Compare October 20, 2023 04:19
@renovate renovate bot changed the title chore(deps): update dependency fastapi to v0.104.0 chore(deps): update dependency fastapi to v0.104.1 Oct 30, 2023
@renovate renovate bot force-pushed the renovate/fastapi-0.x branch 4 times, most recently from d57452a to 064f4b6 Compare November 13, 2023 07:12
@renovate renovate bot changed the title chore(deps): update dependency fastapi to v0.105.0 chore(deps): update dependency fastapi to v0.106.0 Dec 25, 2023
@renovate renovate bot changed the title chore(deps): update dependency fastapi to v0.106.0 chore(deps): update dependency fastapi to v0.108.0 Dec 26, 2023
@renovate renovate bot force-pushed the renovate/fastapi-0.x branch 5 times, most recently from b3af0ac to 8c3868d Compare January 2, 2024 15:24
@renovate renovate bot changed the title chore(deps): update dependency fastapi to v0.108.0 chore(deps): update dependency fastapi to v0.109.0 Jan 11, 2024
@renovate renovate bot force-pushed the renovate/fastapi-0.x branch 6 times, most recently from a8df497 to 2a636c3 Compare January 17, 2024 13:44
@renovate renovate bot changed the title chore(deps): update dependency fastapi to v0.109.0 chore(deps): update dependency fastapi to v0.109.1 Feb 3, 2024
@renovate renovate bot force-pushed the renovate/fastapi-0.x branch 3 times, most recently from a1a43e0 to 36d8e6b Compare February 4, 2024 22:35
@renovate renovate bot changed the title chore(deps): update dependency fastapi to v0.109.1 chore(deps): update dependency fastapi to v0.109.2 Feb 4, 2024
@renovate renovate bot force-pushed the renovate/fastapi-0.x branch 3 times, most recently from bbcd473 to 2222d7c Compare February 25, 2024 01:00
@renovate renovate bot changed the title chore(deps): update dependency fastapi to v0.109.2 chore(deps): update dependency fastapi to v0.110.0 Feb 25, 2024
@renovate renovate bot force-pushed the renovate/fastapi-0.x branch 2 times, most recently from df38152 to 01fe06a Compare March 1, 2024 18:38
@andresmoschini andresmoschini merged commit 0816024 into main Mar 1, 2024
2 checks passed
@andresmoschini andresmoschini deleted the renovate/fastapi-0.x branch March 1, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant