This is an automated email from the ASF dual-hosted git repository.
pierrejeambrun pushed a commit to branch v3-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-3-test by this push:
new 389b17a9383 Fix HTTP_422_UNPROCESSABLE_ENTITY deprecation warnings.
(#69415) (#70745)
389b17a9383 is described below
commit 389b17a93833408fd5b3e31497423c596b2460eb
Author: Rahul Vats <[email protected]>
AuthorDate: Thu Jul 30 21:49:38 2026 +0530
Fix HTTP_422_UNPROCESSABLE_ENTITY deprecation warnings. (#69415) (#70745)
* Fix HTTP_422_UNPROCESSABLE_ENTITY deprecation warnings.
* Fix static check.
(cherry picked from commit f24e272d1159277fd21955a51afc2c0ed6a7959f)
Co-authored-by: Karthikeyan Singaravelan <[email protected]>
---
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 00cae2bbdd1..f1c28a2cd42 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 FastAPI, HTTPException, Request, status
from sqlalchemy.exc import DataError, IntegrityError, SQLAlchemyError
+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
@@ -143,7 +144,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 2799a49cd41..a72c51ada26 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,
@@ -96,7 +97,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]}",
)
@@ -349,7 +350,7 @@ def test_connection(test_body: ConnectionBody) ->
ConnectionTestResponse:
[
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 b9b18c893d0..503038c1f2e 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"