diff --git a/airflow-core/docs/howto/custom-view-plugin.rst b/airflow-core/docs/howto/custom-view-plugin.rst index 3520de1a652ec..024c32f96132d 100644 --- a/airflow-core/docs/howto/custom-view-plugin.rst +++ b/airflow-core/docs/howto/custom-view-plugin.rst @@ -118,7 +118,7 @@ Create an Airflow plugin that serves your React application: from pathlib import Path from fastapi import FastAPI - from starlette.staticfiles import StaticFiles + from fastapi.staticfiles import StaticFiles import mimetypes from airflow.plugins_manager import AirflowPlugin diff --git a/airflow-core/src/airflow/api_fastapi/app.py b/airflow-core/src/airflow/api_fastapi/app.py index 337d09b2ce36b..351074b388c78 100644 --- a/airflow-core/src/airflow/api_fastapi/app.py +++ b/airflow-core/src/airflow/api_fastapi/app.py @@ -22,7 +22,7 @@ from urllib.parse import urlsplit from fastapi import FastAPI -from starlette.routing import Mount +from fastapi.routing import Mount from airflow.api_fastapi.common.dagbag import create_dag_bag from airflow.api_fastapi.core_api.app import ( diff --git a/airflow-core/src/airflow/api_fastapi/auth/managers/simple/routes/login.py b/airflow-core/src/airflow/api_fastapi/auth/managers/simple/routes/login.py index 372aecf603525..2233de8e0b5b6 100644 --- a/airflow-core/src/airflow/api_fastapi/auth/managers/simple/routes/login.py +++ b/airflow-core/src/airflow/api_fastapi/auth/managers/simple/routes/login.py @@ -18,7 +18,7 @@ from __future__ import annotations from fastapi import Depends, Request, status -from starlette.responses import RedirectResponse +from fastapi.responses import RedirectResponse from airflow.api_fastapi.auth.managers.base_auth_manager import COOKIE_NAME_JWT_TOKEN from airflow.api_fastapi.auth.managers.simple.datamodels.login import LoginBody, LoginResponse diff --git a/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py b/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py index 301526d7da502..d3c9792777899 100644 --- a/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py +++ b/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py @@ -28,11 +28,10 @@ from pathlib import Path from typing import TYPE_CHECKING, Any, TextIO -from fastapi import FastAPI -from starlette.requests import Request -from starlette.responses import HTMLResponse -from starlette.staticfiles import StaticFiles -from starlette.templating import Jinja2Templates +from fastapi import FastAPI, Request +from fastapi.responses import HTMLResponse +from fastapi.staticfiles import StaticFiles +from fastapi.templating import Jinja2Templates from termcolor import colored from airflow.api_fastapi.app import AUTH_MANAGER_FASTAPI_APP_PREFIX diff --git a/airflow-core/src/airflow/api_fastapi/common/parameters.py b/airflow-core/src/airflow/api_fastapi/common/parameters.py index 2f60b13b27ee4..b3b49480de027 100644 --- a/airflow-core/src/airflow/api_fastapi/common/parameters.py +++ b/airflow-core/src/airflow/api_fastapi/common/parameters.py @@ -779,7 +779,7 @@ def _transform_dag_run_states(states: Iterable[str] | None) -> list[DagRunState return [None if s in ("none", None) else DagRunState(s) for s in states] except ValueError: raise HTTPException( - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + status_code=status.HTTP_422_UNPROCESSABLE_CONTENT, detail=f"Invalid value for state. Valid values are {', '.join(DagRunState)}", ) @@ -805,7 +805,7 @@ def _transform_dag_run_types(types: list[str] | None) -> list[DagRunType | None] return [None if run_type in ("none", None) else DagRunType(run_type) for run_type in types] except ValueError: raise HTTPException( - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + status_code=status.HTTP_422_UNPROCESSABLE_CONTENT, detail=f"Invalid value for run type. Valid values are {', '.join(DagRunType)}", ) @@ -843,7 +843,7 @@ def _transform_ti_states(states: list[str] | None) -> list[TaskInstanceState | N return [None if s in ("no_status", "none", None) else TaskInstanceState(s) for s in states] except ValueError: raise HTTPException( - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + status_code=status.HTTP_422_UNPROCESSABLE_CONTENT, detail=f"Invalid value for state. Valid values are {', '.join(TaskInstanceState)}", ) diff --git a/airflow-core/src/airflow/api_fastapi/core_api/app.py b/airflow-core/src/airflow/api_fastapi/core_api/app.py index 8db1fa66680bc..d4178c0ea1319 100644 --- a/airflow-core/src/airflow/api_fastapi/core_api/app.py +++ b/airflow-core/src/airflow/api_fastapi/core_api/app.py @@ -22,13 +22,12 @@ import warnings from pathlib import Path -from fastapi import FastAPI +from fastapi import FastAPI, Request from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.gzip import GZipMiddleware -from starlette.requests import Request -from starlette.responses import HTMLResponse, JSONResponse -from starlette.staticfiles import StaticFiles -from starlette.templating import Jinja2Templates +from fastapi.responses import HTMLResponse, JSONResponse +from fastapi.staticfiles import StaticFiles +from fastapi.templating import Jinja2Templates from airflow.api_fastapi.auth.tokens import get_signing_key from airflow.exceptions import AirflowException diff --git a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py index b3ca1b7750941..2c425bc2e6c12 100644 --- a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py +++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py @@ -177,7 +177,7 @@ def get_dags( [ status.HTTP_400_BAD_REQUEST, status.HTTP_404_NOT_FOUND, - status.HTTP_422_UNPROCESSABLE_ENTITY, + status.HTTP_422_UNPROCESSABLE_CONTENT, ] ), dependencies=[Depends(requires_access_dag(method="GET"))], @@ -401,7 +401,7 @@ def unfavorite_dag(dag_id: str, session: SessionDep, user: GetUserDep): [ status.HTTP_400_BAD_REQUEST, status.HTTP_404_NOT_FOUND, - status.HTTP_422_UNPROCESSABLE_ENTITY, + status.HTTP_422_UNPROCESSABLE_CONTENT, ] ), dependencies=[Depends(requires_access_dag(method="DELETE")), Depends(action_logging())], diff --git a/airflow-core/src/airflow/api_fastapi/execution_api/routes/dag_runs.py b/airflow-core/src/airflow/api_fastapi/execution_api/routes/dag_runs.py index b3a99bf21a3db..f7d9451c2fc68 100644 --- a/airflow-core/src/airflow/api_fastapi/execution_api/routes/dag_runs.py +++ b/airflow-core/src/airflow/api_fastapi/execution_api/routes/dag_runs.py @@ -48,7 +48,7 @@ status.HTTP_400_BAD_REQUEST: {"description": "DAG has import errors and cannot be triggered"}, status.HTTP_404_NOT_FOUND: {"description": "DAG not found for the given dag_id"}, status.HTTP_409_CONFLICT: {"description": "DAG Run already exists for the given dag_id"}, - status.HTTP_422_UNPROCESSABLE_ENTITY: {"description": "Invalid payload"}, + status.HTTP_422_UNPROCESSABLE_CONTENT: {"description": "Invalid payload"}, }, ) def trigger_dag_run( @@ -100,7 +100,7 @@ def trigger_dag_run( responses={ status.HTTP_400_BAD_REQUEST: {"description": "DAG has import errors and cannot be triggered"}, status.HTTP_404_NOT_FOUND: {"description": "DAG not found for the given dag_id"}, - status.HTTP_422_UNPROCESSABLE_ENTITY: {"description": "Invalid payload"}, + status.HTTP_422_UNPROCESSABLE_CONTENT: {"description": "Invalid payload"}, }, ) def clear_dag_run( diff --git a/airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py b/airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py index 6dc4101d851ff..fbfcebc54056c 100644 --- a/airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py +++ b/airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py @@ -95,7 +95,7 @@ responses={ status.HTTP_404_NOT_FOUND: {"description": "Task Instance not found"}, status.HTTP_409_CONFLICT: {"description": "The TI is already in the requested state"}, - status.HTTP_422_UNPROCESSABLE_ENTITY: {"description": "Invalid payload for the state transition"}, + status.HTTP_422_UNPROCESSABLE_CONTENT: {"description": "Invalid payload for the state transition"}, }, response_model_exclude_unset=True, ) @@ -336,7 +336,7 @@ def _get_upstream_map_indexes( responses={ status.HTTP_404_NOT_FOUND: {"description": "Task Instance not found"}, status.HTTP_409_CONFLICT: {"description": "The TI is already in the requested state"}, - status.HTTP_422_UNPROCESSABLE_ENTITY: {"description": "Invalid payload for the state transition"}, + status.HTTP_422_UNPROCESSABLE_CONTENT: {"description": "Invalid payload for the state transition"}, }, ) def ti_update_state( @@ -580,7 +580,7 @@ def _create_ti_state_update_query_and_update_state( status_code=status.HTTP_204_NO_CONTENT, responses={ status.HTTP_404_NOT_FOUND: {"description": "Task Instance not found"}, - status.HTTP_422_UNPROCESSABLE_ENTITY: {"description": "Invalid payload for the state transition"}, + status.HTTP_422_UNPROCESSABLE_CONTENT: {"description": "Invalid payload for the state transition"}, }, ) def ti_skip_downstream( @@ -627,7 +627,7 @@ def ti_skip_downstream( status.HTTP_409_CONFLICT: { "description": "The TI attempting to heartbeat should be terminated for the given reason" }, - status.HTTP_422_UNPROCESSABLE_ENTITY: {"description": "Invalid payload for the state transition"}, + status.HTTP_422_UNPROCESSABLE_CONTENT: {"description": "Invalid payload for the state transition"}, }, ) def ti_heartbeat( @@ -702,7 +702,7 @@ def ti_heartbeat( # TODO: Do we need to use create_openapi_http_exception_doc here? responses={ status.HTTP_404_NOT_FOUND: {"description": "Task Instance not found"}, - status.HTTP_422_UNPROCESSABLE_ENTITY: { + status.HTTP_422_UNPROCESSABLE_CONTENT: { "description": "Invalid payload for the setting rendered task instance fields" }, }, @@ -734,7 +734,7 @@ def ti_put_rtif( status_code=status.HTTP_204_NO_CONTENT, responses={ status.HTTP_404_NOT_FOUND: {"description": "Task Instance not found"}, - status.HTTP_422_UNPROCESSABLE_ENTITY: {"description": "Invalid rendered_map_index value"}, + status.HTTP_422_UNPROCESSABLE_CONTENT: {"description": "Invalid rendered_map_index value"}, }, ) def ti_patch_rendered_map_index( @@ -749,7 +749,7 @@ def ti_patch_rendered_map_index( if not rendered_map_index: log.error("rendered_map_index cannot be empty") raise HTTPException( - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + status_code=status.HTTP_422_UNPROCESSABLE_CONTENT, detail="rendered_map_index cannot be empty", ) diff --git a/providers/amazon/src/airflow/providers/amazon/aws/auth_manager/routes/login.py b/providers/amazon/src/airflow/providers/amazon/aws/auth_manager/routes/login.py index c3ca59a28c140..e41658f45cc02 100644 --- a/providers/amazon/src/airflow/providers/amazon/aws/auth_manager/routes/login.py +++ b/providers/amazon/src/airflow/providers/amazon/aws/auth_manager/routes/login.py @@ -21,9 +21,8 @@ from typing import Any import anyio -from fastapi import HTTPException, Request -from starlette import status -from starlette.responses import RedirectResponse +from fastapi import HTTPException, Request, status +from fastapi.responses import RedirectResponse from airflow.api_fastapi.app import ( AUTH_MANAGER_FASTAPI_APP_PREFIX, diff --git a/providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/routes/login.py b/providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/routes/login.py index fd728c78a11bd..bfa3c6549cb8d 100644 --- a/providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/routes/login.py +++ b/providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/routes/login.py @@ -16,9 +16,8 @@ # under the License. from __future__ import annotations -from starlette import status -from starlette.requests import Request # noqa: TC002 -from starlette.responses import RedirectResponse +from fastapi import Request, status +from fastapi.responses import RedirectResponse from airflow.api_fastapi.app import get_auth_manager from airflow.api_fastapi.auth.managers.base_auth_manager import COOKIE_NAME_JWT_TOKEN diff --git a/providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/services/login.py b/providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/services/login.py index 7024581137de3..f0bd0667b7a35 100644 --- a/providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/services/login.py +++ b/providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/services/login.py @@ -18,9 +18,8 @@ from typing import TYPE_CHECKING, cast +from fastapi import HTTPException, status from flask_appbuilder.const import AUTH_LDAP -from starlette import status -from starlette.exceptions import HTTPException from airflow.api_fastapi.app import get_auth_manager from airflow.configuration import conf diff --git a/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py b/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py index eaf98737394f0..f898c599effcc 100644 --- a/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py +++ b/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py @@ -26,10 +26,10 @@ import packaging.version from connexion import FlaskApi from fastapi import FastAPI +from fastapi.middleware.wsgi import WSGIMiddleware from flask import Blueprint, current_app, g from sqlalchemy import select from sqlalchemy.orm import Session, joinedload -from starlette.middleware.wsgi import WSGIMiddleware from airflow import __version__ as airflow_version from airflow.api_fastapi.app import AUTH_MANAGER_FASTAPI_APP_PREFIX diff --git a/providers/fab/tests/unit/fab/auth_manager/api_fastapi/services/test_login.py b/providers/fab/tests/unit/fab/auth_manager/api_fastapi/services/test_login.py index 570ee4aab1051..3eabb756770c2 100644 --- a/providers/fab/tests/unit/fab/auth_manager/api_fastapi/services/test_login.py +++ b/providers/fab/tests/unit/fab/auth_manager/api_fastapi/services/test_login.py @@ -20,8 +20,8 @@ from unittest.mock import ANY, MagicMock, patch import pytest +from fastapi import HTTPException from flask_appbuilder.const import AUTH_DB, AUTH_LDAP -from starlette.exceptions import HTTPException from airflow.providers.fab.auth_manager.api_fastapi.services.login import FABAuthManagerLogin diff --git a/providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/login.py b/providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/login.py index 247f0c4cbd9f4..9507bed76250c 100644 --- a/providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/login.py +++ b/providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/login.py @@ -21,7 +21,7 @@ from typing import Annotated from fastapi import Depends, Request -from starlette.responses import HTMLResponse, RedirectResponse +from fastapi.responses import HTMLResponse, RedirectResponse from airflow.api_fastapi.app import get_auth_manager from airflow.api_fastapi.auth.managers.base_auth_manager import COOKIE_NAME_JWT_TOKEN diff --git a/providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/token.py b/providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/token.py index b3bb1bc1ff331..a8338ed639760 100644 --- a/providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/token.py +++ b/providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/token.py @@ -19,7 +19,7 @@ import logging -from starlette import status +from fastapi import status from airflow.api_fastapi.common.router import AirflowRouter from airflow.api_fastapi.core_api.openapi.exceptions import create_openapi_http_exception_doc diff --git a/providers/keycloak/src/airflow/providers/keycloak/auth_manager/services/token.py b/providers/keycloak/src/airflow/providers/keycloak/auth_manager/services/token.py index 754966d7520ee..448414524ef3f 100644 --- a/providers/keycloak/src/airflow/providers/keycloak/auth_manager/services/token.py +++ b/providers/keycloak/src/airflow/providers/keycloak/auth_manager/services/token.py @@ -17,9 +17,8 @@ from __future__ import annotations -from fastapi import HTTPException +from fastapi import HTTPException, status from keycloak import KeycloakAuthenticationError -from starlette import status from airflow.api_fastapi.app import get_auth_manager from airflow.configuration import conf