Skip to content

Fix xcom_pull() ignoring default parameter when map_indexes not set#64614

Open
nagasrisai wants to merge 9 commits intoapache:mainfrom
nagasrisai:fix/xcom-pull-default-no-map-indexes
Open

Fix xcom_pull() ignoring default parameter when map_indexes not set#64614
nagasrisai wants to merge 9 commits intoapache:mainfrom
nagasrisai:fix/xcom-pull-default-no-map-indexes

Conversation

@nagasrisai
Copy link
Copy Markdown
Contributor

Fix xcom_pull() ignoring the default parameter when map_indexes is not set.

When map_indexes is not explicitly provided, xcom_pull() iterates over each task_id and calls XCom.get_all(). If get_all() returns None (meaning no XCom exists for that task), the code was unconditionally appending None to the results list instead of the caller-supplied default value. The explicit map_indexes path did not have this bug.

One-line fix: xcoms.append(None)xcoms.append(default).

Closes #64295

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
@nagasrisai nagasrisai marked this pull request as ready for review April 5, 2026 04:49
@Dev-iL
Copy link
Copy Markdown
Collaborator

Dev-iL commented Apr 6, 2026

@anishgirianish somewhat related to what you've been working on recently. WDYT?

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Apr 6, 2026
@anishgirianish
Copy link
Copy Markdown
Contributor

anishgirianish commented Apr 7, 2026

@anishgirianish somewhat related to what you've been working on recently. WDYT?

@Dev-iL Thanks for the ping! fix looks good to me, left a couple of small thoughts on the test

@kaxil kaxil requested a review from Copilot April 10, 2026 19:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_indexes path to append default instead of None when no XComs are found.
  • Add a regression test covering the default behavior when map_indexes is not provided and XCom.get_all() returns None.
  • 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.

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

Labels

area:task-sdk ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xcom_pull() ignores default parameter when map_indexes is not set

5 participants