This is an automated email from the ASF dual-hosted git repository.
pierrejeambrun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new f24e272d115 Fix HTTP_422_UNPROCESSABLE_ENTITY deprecation warnings.
(#69415)
f24e272d115 is described below
commit f24e272d1159277fd21955a51afc2c0ed6a7959f
Author: Karthikeyan Singaravelan <[email protected]>
AuthorDate: Mon Jul 6 15:26:57 2026 +0530
Fix HTTP_422_UNPROCESSABLE_ENTITY deprecation warnings. (#69415)
* Fix HTTP_422_UNPROCESSABLE_ENTITY deprecation warnings.
* Fix static check.
---
airflow-core/src/airflow/api_fastapi/common/exceptions.py | 3 ++-
.../src/airflow/api_fastapi/core_api/routes/public/connections.py | 5 +++--
airflow-core/tests/unit/api_fastapi/common/test_exceptions.py | 7 ++++---
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/airflow-core/src/airflow/api_fastapi/common/exceptions.py
b/airflow-core/src/airflow/api_fastapi/common/exceptions.py
index 29d7c453940..6a80d302c3b 100644
--- a/airflow-core/src/airflow/api_fastapi/common/exceptions.py
+++ b/airflow-core/src/airflow/api_fastapi/common/exceptions.py
@@ -26,6 +26,7 @@ from typing import Generic, TypeVar
from fastapi import HTTPException, Request, status
from sqlalchemy.exc import DatabaseError, DataError, IntegrityError
+from airflow.api_fastapi.compat import HTTP_422_UNPROCESSABLE_CONTENT
from airflow.configuration import conf
from airflow.exceptions import DeserializationError
from airflow.utils.strings import get_random_string
@@ -137,7 +138,7 @@ class DataErrorHandler(_DatabaseErrorHandler[DataError]):
range, or the wrong type for its column), so it is a client error, not a
500.
"""
- status_code = status.HTTP_422_UNPROCESSABLE_ENTITY
+ status_code = HTTP_422_UNPROCESSABLE_CONTENT
reason = "Value rejected by database"
def __init__(self):
diff --git
a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/connections.py
b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/connections.py
index 0d122946208..c1d89c89798 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/connections.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/connections.py
@@ -36,6 +36,7 @@ from airflow.api_fastapi.common.parameters import (
SortParam,
)
from airflow.api_fastapi.common.router import AirflowRouter
+from airflow.api_fastapi.compat import HTTP_422_UNPROCESSABLE_CONTENT
from airflow.api_fastapi.core_api.datamodels.common import (
BulkBody,
BulkResponse,
@@ -97,7 +98,7 @@ def _ensure_executor_is_configured(executor: str | None) ->
None:
executor in (name.alias, name.module_path,
name.module_path.split(".")[-1]) for name in configured
):
raise HTTPException(
- status.HTTP_422_UNPROCESSABLE_ENTITY,
+ HTTP_422_UNPROCESSABLE_CONTENT,
f"Executor '{executor}' is not configured. "
f"Configured executors: {[name.alias or name.module_path for name
in configured]}",
)
@@ -371,7 +372,7 @@ def test_connection(
[
status.HTTP_403_FORBIDDEN,
status.HTTP_409_CONFLICT,
- status.HTTP_422_UNPROCESSABLE_ENTITY,
+ HTTP_422_UNPROCESSABLE_CONTENT,
]
),
dependencies=[Depends(action_logging())],
diff --git a/airflow-core/tests/unit/api_fastapi/common/test_exceptions.py
b/airflow-core/tests/unit/api_fastapi/common/test_exceptions.py
index 82893a202b6..118f0b1a5d7 100644
--- a/airflow-core/tests/unit/api_fastapi/common/test_exceptions.py
+++ b/airflow-core/tests/unit/api_fastapi/common/test_exceptions.py
@@ -34,6 +34,7 @@ from airflow.api_fastapi.common.exceptions import (
_DatabaseDialect,
_UniqueConstraintErrorHandler,
)
+from airflow.api_fastapi.compat import HTTP_422_UNPROCESSABLE_CONTENT
from airflow.configuration import conf
from airflow.exceptions import DeserializationError
from airflow.models import DagRun, Pool, Variable
@@ -453,7 +454,7 @@ class TestDataErrorHandler:
exc = self._make_data_error(orig_msg)
with pytest.raises(HTTPException) as exc_info:
self.handler.exception_handler(Mock(), exc)
- assert exc_info.value.status_code ==
status.HTTP_422_UNPROCESSABLE_ENTITY
+ assert exc_info.value.status_code == HTTP_422_UNPROCESSABLE_CONTENT
assert exc_info.value.detail == {
"reason": "Value rejected by database",
"statement": "hidden",
@@ -472,7 +473,7 @@ class TestDataErrorHandler:
exc = self._make_data_error(orig_msg)
with pytest.raises(HTTPException) as exc_info:
self.handler.exception_handler(Mock(), exc)
- assert exc_info.value.status_code ==
status.HTTP_422_UNPROCESSABLE_ENTITY
+ assert exc_info.value.status_code == HTTP_422_UNPROCESSABLE_CONTENT
detail = exc_info.value.detail
assert isinstance(detail, dict)
assert detail["reason"] == "Value rejected by database"
@@ -491,7 +492,7 @@ class TestDataErrorHandler:
raise self._make_data_error("(1406, \"Data too long for column
'conf' at row 1\")")
response = TestClient(app, raise_server_exceptions=False).post("/test")
- assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
+ assert response.status_code == HTTP_422_UNPROCESSABLE_CONTENT
detail = response.json()["detail"]
assert detail["reason"] == "Value rejected by database"
assert detail["statement"] == "hidden"