Skip to content

xcom_pull() ignores default parameter when map_indexes is not set #64295

@yunhobb

Description

@yunhobb

Apache Airflow version

main (development)

What happened and how to reproduce it?

Issue Description

In RuntimeTaskInstance.xcom_pull(), when map_indexes is not specified (default NOTSET path), the code always appends None instead of user-provided default value when no XCom is found.

Location: task-sdk/src/airflow/sdk/execution_time/task_runner.py L420

  • Current: xcoms.append(None)
  • Expected: xcoms.append(default)

The explicit map_indexes branch (L419-426) handles default correctly.

Steps to reproduce:

result = ti.xcom_pull(
    task_ids="some_task",
    key="some_key",
    default="fallback",
)
# Expected: "fallback"
# Actual: None

What you think should happen instead?

xcom_pull() should return user-provided default value when no XCom is found, as described in the docstring:

▎ "default (None if not specified) is returned if no matching XComs are found."

This also affects PlainXComArg.resolve() which passes default=NOTSET. Due to this bug, None is returned instead of NOTSET, so XComNotFound is never raised for custom XCom keys.

Operating System

N/A (code-level bug)

Versions of Apache Airflow Providers

N/A

Deployment

Other

Deployment details

N/A

Anything else?

This bug happens every time xcom_pull() is called without explicit map_indexes and no matching XCom exists. Already have a fix ready with tests.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected_version:3.2Use for reporting issues with 3.2area:corekind:bugThis is a clearly a bugpriority:mediumBug that should be fixed before next release but would not block a release

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions