Skip to content

Conversation

@kevinhongzl
Copy link
Contributor

@kevinhongzl kevinhongzl commented Oct 2, 2025

closes: #56289 (also close #43635)

Why this change

This PR resolves the issue where the api endpoint clearTaskInstance fails to operate on mapped TIs. Previously, there were cases that we could not clear mapped tasks individually even when their map indices were provided in payload.

Solution

  • Fix the logic for how relative tasks (upstream & downstream) are added to task_ids. This was the root cause of the failure to clear single mapped tasks.
  • Add corresponding tests.
  • Explicitly describe the usage of task_ids (i.e. how to include map indices to reference specific mapped task instances)

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:serialization labels Oct 2, 2025
@seanghaeli
Copy link
Contributor

I think you need to rebase main, some of the CI tests are failing because of that.

Also, it seems that the changes don't reference the map_indexes at all?

@kevinhongzl kevinhongzl force-pushed the api-support-clear-ti-by-map-index branch 2 times, most recently from fc50916 to 08fd98c Compare October 3, 2025 21:16
@kevinhongzl
Copy link
Contributor Author

Appreciate your comments and review @seanghaeli !

As I'm working on this issue, I also reviewed relevant PRs and discussions about clearing task instances in AF2 (#22958, #24699, #45349). Currently, we are clearing multiple mapped tasks by passing a list of tuples [task_id, map_index].

There is no map_indexes introduced to this api endpoint because it would lead to confusion (e.g., what tasks would be referenced if we provide such a payload: "task_ids":["task1", ["task2, 0]], "map_indexes": 1)

However, your comments reminded me that it might be unclear for users how to include the map index when using this endpoint. I'll improve the descriptions and documentation as well. Thank you!

Copy link
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I will talk a closer look for over all structure later.

Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few nits.

@kevinhongzl kevinhongzl force-pushed the api-support-clear-ti-by-map-index branch 4 times, most recently from 8153adb to 16f8bf8 Compare October 15, 2025 04:45
@kevinhongzl kevinhongzl force-pushed the api-support-clear-ti-by-map-index branch from 16f8bf8 to 0223959 Compare October 15, 2025 14:48
@pierrejeambrun pierrejeambrun added this to the Airflow 3.1.1 milestone Oct 20, 2025
@pierrejeambrun pierrejeambrun added the backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch label Oct 20, 2025
Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good to me.

I just pushed a really small adjustment commit for these nits, ready to merge.

@pierrejeambrun pierrejeambrun force-pushed the api-support-clear-ti-by-map-index branch from 461de61 to 56c6a84 Compare October 20, 2025 13:43
@pierrejeambrun pierrejeambrun merged commit 800f733 into apache:main Oct 21, 2025
213 of 214 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 21, 2025
…ndexes (#56346)

* fix: enable api to clear ti instances by specifying map indexes

* chore: add tests for clearing mapped task instances from api endpoint

* chore: add descriptions to task_ids in the payload

* fix: deal with tests that were broken when map_indexes was introduced

* chore: generate datamodel and api spec

* chore: rewrite clear task_ids for clarity and remove duplicate tasks

* Small adjustments

---------
(cherry picked from commit 800f733)

Co-authored-by: Zhen-Lun (Kevin) Hong <zhenlun.hong01@gmail.com>
Co-authored-by: pierrejeambrun <pierrejbrun@gmail.com>
@github-actions
Copy link

Backport successfully created: v3-1-test

Status Branch Result
v3-1-test PR Link

pierrejeambrun added a commit that referenced this pull request Oct 21, 2025
…ndexes (#56346) (#56945)

* fix: enable api to clear ti instances by specifying map indexes

* chore: add tests for clearing mapped task instances from api endpoint

* chore: add descriptions to task_ids in the payload

* fix: deal with tests that were broken when map_indexes was introduced

* chore: generate datamodel and api spec

* chore: rewrite clear task_ids for clarity and remove duplicate tasks

* Small adjustments

---------
(cherry picked from commit 800f733)

Co-authored-by: Zhen-Lun (Kevin) Hong <zhenlun.hong01@gmail.com>
Co-authored-by: pierrejeambrun <pierrejbrun@gmail.com>
Jonpaco23 pushed a commit to Jonpaco23/airflow that referenced this pull request Oct 21, 2025
…he#56346)

* fix: enable api to clear ti instances by specifying map indexes

* chore: add tests for clearing mapped task instances from api endpoint

* chore: add descriptions to task_ids in the payload

* fix: deal with tests that were broken when map_indexes was introduced

* chore: generate datamodel and api spec

* chore: rewrite clear task_ids for clarity and remove duplicate tasks

* Small adjustments

---------

Co-authored-by: pierrejeambrun <pierrejbrun@gmail.com>
@kevinhongzl
Copy link
Contributor Author

@pierrejeambrun Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:serialization backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API - Clearing specific Ti map index Add support for map_index in /clearTaskInstances

4 participants