This is an automated email from the ASF dual-hosted git repository.
jasonliu pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-1-test by this push:
new cdd58e928ed [v3-1-test] [API] Use BulkTaskInstanceBody for patching
tis with new state (#57226) (#57412)
cdd58e928ed is described below
commit cdd58e928ed30ee05336748bb9615f53b556d196
Author: LIU ZHE YOU <[email protected]>
AuthorDate: Tue Oct 28 18:54:37 2025 +0800
[v3-1-test] [API] Use BulkTaskInstanceBody for patching tis with new state
(#57226) (#57412)
---
.../api_fastapi/core_api/routes/public/task_instances.py | 14 +++++++++++++-
.../core_api/routes/public/test_task_instances.py | 13 +++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git
a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py
b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py
index d31a5f8ba8e..7169b34145a 100644
---
a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py
+++
b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py
@@ -909,11 +909,23 @@ def patch_task_instance(
for key, _ in data.items():
if key == "new_state":
+ # Create BulkTaskInstanceBody object with map_index field
+ bulk_ti_body = BulkTaskInstanceBody(
+ task_id=task_id,
+ map_index=map_index,
+ new_state=body.new_state,
+ note=body.note,
+ include_upstream=body.include_upstream,
+ include_downstream=body.include_downstream,
+ include_future=body.include_future,
+ include_past=body.include_past,
+ )
+
_patch_task_instance_state(
task_id=task_id,
dag_run_id=dag_run_id,
dag=dag,
- task_instance_body=body,
+ task_instance_body=bulk_ti_body,
data=data,
session=session,
)
diff --git
a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_task_instances.py
b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_task_instances.py
index d2303da24a4..55db52a0e52 100644
---
a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_task_instances.py
+++
b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_task_instances.py
@@ -3701,8 +3701,16 @@ class TestPatchTaskInstance(TestTaskInstanceEndpoint):
ti = TaskInstance(
task=tis[0].task, run_id=tis[0].run_id, map_index=map_index,
dag_version_id=tis[0].dag_version_id
)
+ ti_2 = TaskInstance(
+ task=tis[0].task,
+ run_id=tis[0].run_id,
+ map_index=map_index + 1,
+ dag_version_id=tis[0].dag_version_id,
+ )
ti.rendered_task_instance_fields = RTIF(ti, render_templates=False)
+ ti_2.rendered_task_instance_fields = RTIF(ti_2, render_templates=False)
session.add(ti)
+ session.add(ti_2)
session.commit()
response = test_client.patch(
@@ -3717,6 +3725,11 @@ class TestPatchTaskInstance(TestTaskInstanceEndpoint):
assert response2.status_code == 200
assert response2.json()["state"] == self.NEW_STATE
+ response3 = test_client.get(f"{self.ENDPOINT_URL}/{map_index + 1}")
+ assert response3.status_code == 200
+ assert response3.json()["state"] != self.NEW_STATE
+ assert response3.json()["state"] is None
+
def test_should_update_mapped_task_instance_summary_state(self,
test_client, session):
tis = self.create_task_instances(session)