diff --git a/airflow-core/pyproject.toml b/airflow-core/pyproject.toml index ec41f337dd7ed..1775cbb018d31 100644 --- a/airflow-core/pyproject.toml +++ b/airflow-core/pyproject.toml @@ -75,7 +75,7 @@ dependencies = [ "argcomplete>=1.10", "asgiref>=2.3.0", "attrs>=22.1.0, !=25.2.0", - "cadwyn>=5.2.1", + "cadwyn>=5.6.1", "colorlog>=6.8.2", "cron-descriptor>=1.2.24", "croniter>=2.0.2", @@ -83,7 +83,7 @@ dependencies = [ "cryptography>=41.0.0,<46.0.0", "deprecated>=1.2.13", "dill>=0.2.2", - "fastapi[standard-no-fastapi-cloud-cli]>=0.116.0,<0.118.0", + "fastapi[standard-no-fastapi-cloud-cli]>=0.121.0", "uvicorn>=0.37.0", "starlette>=0.45.0", "httpx>=0.25.0", diff --git a/airflow-core/src/airflow/api_fastapi/common/db/common.py b/airflow-core/src/airflow/api_fastapi/common/db/common.py index e738a3fb758f2..2fd7ac26f90c2 100644 --- a/airflow-core/src/airflow/api_fastapi/common/db/common.py +++ b/airflow-core/src/airflow/api_fastapi/common/db/common.py @@ -43,7 +43,7 @@ def _get_session() -> Generator[Session, None, None]: yield session -SessionDep = Annotated[Session, Depends(_get_session)] +SessionDep = Annotated[Session, Depends(_get_session, scope="function")] def apply_filters_to_select( diff --git a/airflow-core/src/airflow/api_fastapi/logging/decorators.py b/airflow-core/src/airflow/api_fastapi/logging/decorators.py index 4c09f4b5dc834..93e96bef38592 100644 --- a/airflow-core/src/airflow/api_fastapi/logging/decorators.py +++ b/airflow-core/src/airflow/api_fastapi/logging/decorators.py @@ -167,5 +167,8 @@ async def log_action( else: logger.warning("Logical date is missing or empty") session.add(log) + # Explicit commit to persist the access log independently if the path operation fails or not. + # Also it cannot be deferred to a 'function' scoped dependency because of the `request` parameter. + session.commit() return log_action diff --git a/chart/newsfragments/58524.significant.rst b/chart/newsfragments/58524.significant.rst new file mode 100644 index 0000000000000..ef94f296dcf35 --- /dev/null +++ b/chart/newsfragments/58524.significant.rst @@ -0,0 +1,7 @@ +FastAPI dependency is updated and lower bound set to ``0.121.0`` + +Airflow now requires FastAPI ``>=0.121.0`` and removes the previous upper +constraint. This aligns with FastAPI's new dependency lifecycle scopes +(e.g. request/function) that change how dependencies with ``yield`` are +exited. +See `FastAPI PR #14262 `_. diff --git a/task-sdk/dev/generate_task_sdk_models.py b/task-sdk/dev/generate_task_sdk_models.py index bb19fffc4497c..1070dfeb3c5dd 100644 --- a/task-sdk/dev/generate_task_sdk_models.py +++ b/task-sdk/dev/generate_task_sdk_models.py @@ -20,6 +20,7 @@ import os import sys from pathlib import Path +from unittest import mock import httpx from datamodel_code_generator import ( @@ -75,6 +76,7 @@ def load_config(): return cfg +@mock.patch("fastapi._compat.v2.get_long_model_name", lambda model: model.__name__) def generate_file(): from airflow.api_fastapi.execution_api.app import InProcessExecutionAPI