Fix xcom_pull() ignoring default parameter when map_indexes not set#64614
Open
nagasrisai wants to merge 9 commits intoapache:mainfrom
Open
Fix xcom_pull() ignoring default parameter when map_indexes not set#64614nagasrisai wants to merge 9 commits intoapache:mainfrom
nagasrisai wants to merge 9 commits intoapache:mainfrom
Conversation
When map_indexes is not explicitly provided, xcom_pull() calls XCom.get_all() for each task_id. If get_all() returns None (no XCom stored), the code was appending None unconditionally instead of the caller-supplied default value. Fixes apache#64295
Collaborator
|
@anishgirianish somewhat related to what you've been working on recently. WDYT? |
Contributor
@Dev-iL Thanks for the ping! fix looks good to me, left a couple of small thoughts on the test |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes RuntimeTaskInstance.xcom_pull() to respect the caller-provided default value when map_indexes is not set (the NOTSET path), aligning behavior with the explicit map_indexes branch and the method’s documented contract.
Changes:
- Update
xcom_pull()no-map_indexespath to appenddefaultinstead ofNonewhen no XComs are found. - Add a regression test covering the
defaultbehavior whenmap_indexesis not provided andXCom.get_all()returnsNone. - Add a bugfix newsfragment documenting the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| task-sdk/src/airflow/sdk/execution_time/task_runner.py | Fixes xcom_pull() to use default in the no-map_indexes branch when no XCom is found. |
| task-sdk/tests/task_sdk/execution_time/test_task_runner.py | Adds a regression test ensuring default is returned when map_indexes is not specified and no XCom exists. |
| airflow-core/newsfragments/64614.bugfix.rst | Release note entry describing the bugfix. |
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.
Fix
xcom_pull()ignoring thedefaultparameter whenmap_indexesis not set.When
map_indexesis not explicitly provided,xcom_pull()iterates over eachtask_idand callsXCom.get_all(). Ifget_all()returnsNone(meaning no XCom exists for that task), the code was unconditionally appendingNoneto the results list instead of the caller-supplieddefaultvalue. The explicitmap_indexespath did not have this bug.One-line fix:
xcoms.append(None)→xcoms.append(default).Closes #64295