You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2026/05/10 03:37:50 UTC
(airflow) branch main updated: Clarify HttpOperator response_filter XCom usage (#66597)
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 4d30db62c4e Clarify HttpOperator response_filter XCom usage (#66597)
4d30db62c4e is described below
commit 4d30db62c4e69491fb8cb4f7a47dbf9eddd996b5
Author: 백형준 <13...@users.noreply.github.com>
AuthorDate: Sun May 10 12:37:43 2026 +0900
Clarify HttpOperator response_filter XCom usage (#66597)
---
providers/http/docs/operators.rst | 7 ++++---
providers/http/tests/system/http/example_http.py | 3 ++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/providers/http/docs/operators.rst b/providers/http/docs/operators.rst
index 6a1e74d063b..006aaec7ead 100644
--- a/providers/http/docs/operators.rst
+++ b/providers/http/docs/operators.rst
@@ -89,14 +89,15 @@ Here we are calling a ``GET`` request and pass params to it. The task will succe
:end-before: [END howto_operator_http_task_get_op]
HttpOperator returns the response body as text by default. If you want to modify the response before passing
-it on the next task downstream use ``response_filter``. This is useful if:
+it on to the next downstream task, use ``response_filter``. The value returned by ``response_filter`` becomes
+the task result, which can be pulled by downstream tasks with XCom. This is useful if:
- the API you are consuming returns a large JSON payload and you're interested in a subset of the data
- the API returns data in xml or csv and you want to convert it to JSON
- you're interested in the headers of the response instead of the body
-Below is an example of retrieving data from a REST API and only returning a nested property instead of the full
-response body.
+Below is an example of retrieving data from a REST API and only returning the ``status`` query parameter from
+the response body.
.. exampleinclude:: /../../http/tests/system/http/example_http.py
:language: python
diff --git a/providers/http/tests/system/http/example_http.py b/providers/http/tests/system/http/example_http.py
index 3031469baf1..0f62e9e8624 100644
--- a/providers/http/tests/system/http/example_http.py
+++ b/providers/http/tests/system/http/example_http.py
@@ -77,7 +77,8 @@ task_get_op_response_filter = HttpOperator(
task_id="get_op_response_filter",
method="GET",
endpoint="get",
- response_filter=lambda response: response.json()["nested"]["property"],
+ data={"status": "ready"},
+ response_filter=lambda response: response.json()["args"]["status"],
dag=dag,
)
# [END howto_operator_http_task_get_op_response_filter]