Fix mapped task group XCom collapsing to a bare value for a single expansion#69075
Merged
shahar1 merged 6 commits intoJul 1, 2026
Merged
Conversation
2 tasks
shahar1
marked this pull request as draft
June 27, 2026 06:54
shahar1
force-pushed
the
fix-mapped-task-group-single-xcom-list
branch
from
June 27, 2026 07:06
cdf92e6 to
2b8c984
Compare
shahar1
marked this pull request as ready for review
June 27, 2026 07:08
1 task
shahar1
force-pushed
the
fix-mapped-task-group-single-xcom-list
branch
from
June 27, 2026 11:32
2b8c984 to
a28c3f0
Compare
uranusjr
reviewed
Jun 28, 2026
…pansion A task consuming the output of a mapped task group from outside that group must always receive a list with one element per expansion. Since the task-start upstream map-index computation moved into the Task SDK, an unmapped downstream resolving a task inside a mapped task group fell through to pulling all map indexes via xcom_pull, which collapses a single value to a bare scalar and an empty set of values to None. A group that expanded only once therefore handed the raw value to the downstream task instead of a one-element list, and a group whose expansions all returned None handed None instead of an empty list. The pre-3.2 server returned list(range(mapped_ti_count)) for this case, so the behaviour regressed. Resolve this case by eagerly materialising the group's per-expansion XComs into a list (a single slice request), so the result is always a list regardless of how many times the group expanded or whether every value was None, and stays serializable when a task returns it unchanged.
Eagerly materializing the whole mapped task group result at resolve time fetches every expansion even when the downstream task never iterates it, which scales poorly for large maps. Defer the fetch to XCom serialization so it is only paid when the value is actually returned and pushed.
shahar1
force-pushed
the
fix-mapped-task-group-single-xcom-list
branch
from
June 29, 2026 21:38
a28c3f0 to
3b856fd
Compare
uranusjr
reviewed
Jun 30, 2026
uranusjr
approved these changes
Jun 30, 2026
Member
|
Worth checking whether XComArg still accepts ArgNotSet after this change. Maybe we can remove handling for that entirely? |
…gNotSet path Route the lazily-resolved mapped task group value through a registered serde serializer instead of a special case in serialize(), matching how every other custom type is handled, so any returned lazy XCom sequence materializes to a list when pushed. The resolve path no longer produces an unset map-index sentinel, so the corresponding ArgNotSet handling is removed.
The aggregated task group value now resolves to a lazy sequence, so the test's supervisor-comms stub must answer single-item fetches, not only slice fetches, when the resolved value is iterated.
Lee-W
reviewed
Jun 30, 2026
Contributor
Author
|
Thanks TP for approval. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes: #69036
Human Summary
Currently, when
map_indexesis left unset, a single mapped result collapses to its bare value instead of staying one-element list.It started to happen after #60803 was merged, when the upstream map-index computation was relocated to the task-sdk.
This PR fixes it by returning an eagerly-materialized
LazyXComSequenceobject.AI Summary
Click here
A task consuming the output of a mapped task group from **outside** that group must always receive a list with one element per expansion. When the task-start upstream map-index computation moved into the Task SDK (#60803, released in 3.2.0), an unmapped downstream resolving a task inside a mapped task group started falling through to pulling all map indexes via `xcom_pull`, which collapses a single value to a bare scalar and an empty set of values to `None`.As a result:
'14'and iterated'1','4'instead of receiving['14']).Nonewould handNoneinstead of an empty list (the Result of expanded task is None instead of empty list when all mapped tasks return None #48005 class of bug, via the task-group resolution path).This worked correctly in 3.1.5: the pre-3.2 server returned
list(range(mapped_ti_count))for this case, guaranteeing a list. The fix resolves this case through aLazyXComSequence, mirroring how a directly mapped task already resolves, so the result is always a list regardless of how many times the group expanded or whether every value wasNone.Verified end to end with
airflow dags teston the reproduction DAGs from both issues:['14'](was'14'),Nonegroup expansions yield[],Nonecase from Result of expanded task is None instead of empty list when all mapped tasks return None #48005 continues to yield[].Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8) following the guidelines