This is an automated email from the ASF dual-hosted git repository.
potiuk 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 9ccb991e6ea Preserve DELETE request bodies in HttpAsyncHook (#72720)
9ccb991e6ea is described below
commit 9ccb991e6ea94348f1ee74938e7c4af556361643
Author: Jake Wang <[email protected]>
AuthorDate: Sun Sep 20 16:03:52 2026 -0400
Preserve DELETE request bodies in HttpAsyncHook (#72720)
---
.../http/src/airflow/providers/http/hooks/http.py | 2 +-
providers/http/tests/unit/http/hooks/test_http.py | 24 ++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/providers/http/src/airflow/providers/http/hooks/http.py
b/providers/http/src/airflow/providers/http/hooks/http.py
index 3401c589c81..af27f886091 100644
--- a/providers/http/src/airflow/providers/http/hooks/http.py
+++ b/providers/http/src/airflow/providers/http/hooks/http.py
@@ -517,7 +517,7 @@ class AsyncHttpSession(LoggingMixin):
response = await self._request(
url,
params=data if self.method == "GET" else None,
- data=data if self.method in {"POST", "PUT", "PATCH"} else None,
+ data=data if self.method in {"POST", "PUT", "PATCH", "DELETE"}
else None,
json=json,
headers=merged_headers,
auth=self.auth,
diff --git a/providers/http/tests/unit/http/hooks/test_http.py
b/providers/http/tests/unit/http/hooks/test_http.py
index f89532d7e27..31cdb649a39 100644
--- a/providers/http/tests/unit/http/hooks/test_http.py
+++ b/providers/http/tests/unit/http/hooks/test_http.py
@@ -784,6 +784,30 @@ class TestHttpAsyncHook:
resp = await hook.run(session=session, endpoint="v1/test")
assert resp.status == 200
+ @pytest.mark.asyncio
+ @pytest.mark.parametrize("data", [{"item_id": "42"}, "item_id=42"])
+ @pytest.mark.parametrize("use_external_session", [True, False])
+ @mock.patch(
+ "aiohttp.ClientSession.delete", new_callable=mock.AsyncMock,
spec=aiohttp.ClientSession.delete
+ )
+ async def test_async_delete_request_preserves_data(self, mocked_delete,
data, use_external_session):
+ hook = HttpAsyncHook(method="DELETE")
+ response = MockAiohttpClientResponse(
+ status=200,
+ method="DELETE",
+ url="http://test:8080/v1/test",
+ )
+ mocked_delete.return_value = response
+
+ if use_external_session:
+ async with aiohttp.ClientSession() as session:
+ await hook.run(session=session, endpoint="v1/test", data=data)
+ else:
+ await hook.run(endpoint="v1/test", data=data)
+
+ assert mocked_delete.call_args.kwargs["data"] == data
+ assert mocked_delete.call_args.kwargs["params"] is None
+
@pytest.mark.asyncio
async def test_async_post_request_with_error_code(self):
"""Test api call asynchronously for POST request with error."""