Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow-core/docs/howto/custom-view-plugin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion airflow-core/src/airflow/api_fastapi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions airflow-core/src/airflow/api_fastapi/common/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC someone tried this before and it didn’t work

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was this one: #56564

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can use airflow.api_fastapi.compat.HTTP_422_UNPROCESSABLE_CONTENT instead now.

detail=f"Invalid value for state. Valid values are {', '.join(DagRunState)}",
)

Expand All @@ -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)}",
)

Expand Down Expand Up @@ -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)}",
)

Expand Down
9 changes: 4 additions & 5 deletions airflow-core/src/airflow/api_fastapi/core_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))],
Expand Down Expand Up @@ -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())],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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"
},
},
Expand Down Expand Up @@ -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(
Expand All @@ -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",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading