Skip to content

Fix: Skip expansion of mapped task group when list is empty (2.5.1+affirm4)#34

Merged
alanxu00 merged 2 commits into
masterfrom
2.5.1+affirm4_trigger_rule_with_none_mapped_tasks
Jun 16, 2026
Merged

Fix: Skip expansion of mapped task group when list is empty (2.5.1+affirm4)#34
alanxu00 merged 2 commits into
masterfrom
2.5.1+affirm4_trigger_rule_with_none_mapped_tasks

Conversation

@andresvelasquez2-affirm

@andresvelasquez2-affirm andresvelasquez2-affirm commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Ports upstream fix apache/airflow#30084 to our 2.5.1 fork, and bumps the fork version to 2.5.1+affirm4.

Problem

Expanding a mapped task group fails when the input list is empty and a downstream task references a mapped index via XCom pull of that group. In that case, the entire task group should be skipped — instead, the scheduler enters a crash loop.

Root cause: in TaskInstance.get_relevant_upstream_map_indexes, ancestor_map_index is calculated as self.map_index * ancestor_ti_count // ti_count. When a task group is expanded with an empty list, ti_count is 0, causing a ZeroDivisionError.

Fix

Move the early-return guard before the division and broaden it from if ti_count is None to if not ti_count, so both None and 0 short-circuit to returning None (which callers already treat as "no partial mapping — use the whole value / all upstreams").

Changes

  • airflow/models/taskinstance.py — reorder and broaden the ti_count guard in get_relevant_upstream_map_indexes.
  • tests/ti_deps/deps/test_trigger_rule_dep.py — add test_upstream_in_mapped_group_when_mapped_tasks_list_is_empty regression test.
  • setup.py — bump fork version 2.5.1+affirm32.5.1+affirm4.

Compatibility

Signature of get_relevant_upstream_map_indexes is unchanged. Both call sites (airflow/models/xcom_arg.py and airflow/ti_deps/deps/trigger_rule_dep.py) already handle a None return.

Test plan

  • New regression test test_upstream_in_mapped_group_when_mapped_tasks_list_is_empty passes.
  • Existing trigger rule tests continue to pass.

Move ti_count zero/None check before division to prevent ZeroDivisionError in _get_relevant_upstream_map_indexes when a mapped task group is expanded with an empty list, which caused the scheduler to enter a crash loop.

Ports upstream fix; adds regression test covering empty-list expansion with downstream task referencing the group via XCom pull.
@andresvelasquez2-affirm andresvelasquez2-affirm changed the title 2.5.1+affirm4 trigger rule with none mapped tasks Fix: Skip expansion of mapped task group when list is empty (2.5.1+affirm4) Jun 9, 2026
@alanxu00 alanxu00 merged commit 200bf65 into master Jun 16, 2026
3 of 4 checks passed
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