Skip to content

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

Open
nagasrisai wants to merge 6 commits into
apache:mainfrom
nagasrisai:fix/xcom-pull-default-no-map-indexes
Open

nagasrisai wants to merge 6 commits into
apache:mainfrom
nagasrisai:fix/xcom-pull-default-no-map-indexes

Conversation

@nagasrisai

@nagasrisai nagasrisai commented Apr 2, 2026 •

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


Important

🛠️ Maintainer triage note for @nagasrisai · by @potiuk · 2026-07-08 15:51 UTC

Some review feedback from @potiuk is waiting on you (1 unresolved thread):

The ball is in your court — you've been assigned to this PR. Reply or push a fix in each thread, then mark them resolved. See the Pull Request quality criteria.

Automated triage — may be imperfect; a maintainer takes the next look.

nagasrisai added a commit to nagasrisai/airflow that referenced this pull request Apr 2, 2026
@nagasrisai
nagasrisai marked this pull request as ready for review April 5, 2026 04:49
@Dev-iL

Dev-iL commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator

@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
Comment thread task-sdk/src/airflow/sdk/execution_time/task_runner.py
Comment thread task-sdk/tests/task_sdk/execution_time/test_task_runner.py
Comment thread task-sdk/tests/task_sdk/execution_time/test_task_runner.py
@anishgirianish

anishgirianish commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

@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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread airflow-core/newsfragments/64614.bugfix.rst Outdated
@potiuk

potiuk commented Jun 25, 2026

Copy link
Copy Markdown
Member

@nagasrisai — I've removed the ready for maintainer review label because the next step here is yours: there are 1 unresolved review thread(s) awaiting your reply. It'll go back into the maintainer queue automatically once you've addressed them — no need to re-add the label by hand. There's no rush.

Automated triage note drafted by an AI-assisted tool — may get things wrong; a real Apache Airflow maintainer takes the next look once they're resolved. (why automated)


Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting

@potiuk potiuk removed the ready for maintainer review Set after triaging when all criteria pass. label Jun 25, 2026
@potiuk

potiuk commented Jul 20, 2026

Copy link
Copy Markdown
Member

@nagasrisai — There are 1 unresolved review thread(s) on this PR from @eladkal. Could you either push a fix or reply in each thread explaining why the feedback doesn't apply? Once you believe the feedback is addressed, mark the thread as resolved so the reviewer isn't re-pinged needlessly. Thanks!


Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you.

@nagasrisai

nagasrisai commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Done — airflow-core/newsfragments/64614.bugfix.rst has been removed from the branch. Let me know if there's anything else! @potiuk - could you please help me get it reviewed

…not set

On the no-map_indexes code path, both xcom_pull() and axcom_pull() were
unconditionally appending None when XCom.get_all() / XCom.aget_all()
returned nothing, silently ignoring any caller-supplied default value.

Changed both occurrences to append `default` instead of `None`, aligning
the no-map_indexes branch with the explicit-map_indexes branch and the
documented contract of the method.

Also adds three regression tests:
- test_xcom_pull_default_respected_when_no_map_indexes
- test_xcom_pull_default_is_none_when_not_passed_and_no_xcom
- test_xcom_pull_default_fills_correct_position_with_multiple_task_ids
@nagasrisai
nagasrisai force-pushed the fix/xcom-pull-default-no-map-indexes branch from 2bcf86b to 6599089 Compare August 5, 2026 03:38
@nagasrisai

Copy link
Copy Markdown
Contributor Author

@potiuk - Could you please mark this PR as ready for review? It's currently waiting for a reviewer. Thanks!

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks. I confirmed the bug is still present on current main: the map_indexes-not-set branch of xcom_pull / axcom_pull appends None instead of default, while the explicit-map_indexes branch and the docstring already honour default. The fix only applies when XCom.get_all finds no rows at all. A stored null XCom comes back as [None] and is still returned as-is, so legitimately-None values are not replaced by default.

Approving, with two small non-blocking nits inline. Please also rebase onto main so we get a fresh CI run before merging — the current run is from August.

@uranusjr @amoghrajesh — since this changes what xcom_pull returns when nothing was pushed (now default instead of None on the no-map_indexes path), could you take a look as well before it's merged?


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

)
xcoms.append(None) if values is None else xcoms.extend(values)
if values is None:
xcoms.append(default)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This async branch isn't covered: all new tests use the sync xcom_pull. Could you add an async case (e.g. parametrize over sync/async, patching XCom.aget_all)?


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

),
)

def test_xcom_pull_default_respected_when_no_map_indexes(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test and test_xcom_pull_default_is_none_when_not_passed_and_no_xcom differ only in input and expected value — could you fold them into one @pytest.mark.parametrize test?


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

task = CustomOperator(task_id="pull_task")
runtime_ti = create_runtime_ti(task=task)

with patch.object(XCom, "get_all") as mock_get_all:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use autospec=True on the XCom.get_all patches.


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xcom_pull() ignores default parameter when map_indexes is not set

6 participants