apache / apache/airflow

xcom_pull doesn't allow passing key=None or not specifying key in Airflow 3

Open
#51,521 9 comments 0 reactions 0 assignees View on GitHub
affected_version:3.0 area:core kind:bug
Dominant language
Python
Stars
46.9k
Forks
17.8k
Avg merge
2d 10h
Merged PRs (30d)
483

Description

### Apache Airflow version

3.0.1

### If "Other Airflow 2 version" selected, which one?

_No response_

### What happened?

xcoms = context['ti'].xcom_pull(
run_id=run_id,
task_ids=task_ids,
key=None,
)

the above code will report error said key cannot be None:
`Key`
`Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]`

however in Airflow 2 with the above code I can get all xcoms of these tasks in this dag run

### What you think should happen instead?

I expect to get all xcoms of these tasks in this dag run,
means if key=None, it should return all xcoms regardless of their xcom key,

the sql statement may be like:

```
SELECT * from xcom
WHERE run_id=run_id and task_ids in [...]
```
no filter on xcom key

In Airflow 2 this works.

### How to reproduce

xcoms = context['ti'].xcom_pull(
run_id=run_id,
task_ids=task_ids,
key=None,
)

### Operating System

ubuntu

### Versions of Apache Airflow Providers

_No response_

### Deployment

Official Apache Airflow Helm Chart

### Deployment details

_No response_

### Anything else?

_No response_

### Are you willing to submit PR?

- [x] Yes I am willing to submit a PR!

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

Contributor guide

Open the contributing guide

Research direction

Start at the TaskInstance xcom_pull entry point shown in the reproduction and compare its key handling with the reported Airflow 2 behavior. Reproduce the call with key=None and task_ids, then trace the validation and query path. Done means the call returns all matching XComs without filtering by key, with coverage for the demonstrated case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, data-engineering
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.