Skip to content

Fix branch operators inside mapped task groups not skipping siblings - #72594

Closed
sohailiqrar wants to merge 1 commit into
apache:mainfrom
sohailiqrar:fix/branch-in-mapped-taskgroup-not-skipped
Closed

sohailiqrar wants to merge 1 commit into
apache:mainfrom
sohailiqrar:fix/branch-in-mapped-taskgroup-not-skipped

Conversation

@sohailiqrar

@sohailiqrar sohailiqrar commented Sep 6, 2026 •

Copy link
Copy Markdown

When a @task.branch lives inside a mapped @task_group it is not itself expanded (parent.is_mapped is False), but its TI runs at the group's map_index and SkipMixin writes the skip XCom there — not at -1. NotPreviouslySkippedDep was querying map_index=-1 for every unmapped parent, finding no XCom, and letting all siblings proceed regardless of what the branch decided.

Detect whether the parent ran in the same mapped context by checking for a finished parent TI at the child's map_index. If one exists, use that index for the XCom lookup; fall back to -1 only for truly unmapped parents (e.g. LatestOnlyOperator) that always write at -1.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

When a @task.branch lives inside a mapped @task_group it is not itself
expanded (parent.is_mapped is False), but its TI runs at the group's
map_index and SkipMixin writes the skip XCom there — not at -1.
NotPreviouslySkippedDep was querying map_index=-1 for every unmapped
parent, finding no XCom, and letting all siblings proceed regardless
of what the branch decided.

Detect whether the parent ran in the same mapped context by checking
for a finished parent TI at the child's map_index. If one exists, use
that index for the XCom lookup; fall back to -1 only for truly unmapped
parents (e.g. LatestOnlyOperator) that always write at -1.
@kaxil

kaxil commented Oct 1, 2026

Copy link
Copy Markdown
Member

Closing this. #73959 fixed this on main: NotPreviouslySkippedDep now reads xcom_map_index = ti.map_index if parent.get_needs_expansion() else -1, which covers parents inside a mapped task group. The new test also sets map_index = 1 by hand on unmapped tasks rather than building a mapped task group, so it doesn't exercise the case.

@kaxil kaxil closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants