`xcom_pull()` ignores `default` parameter when `map_indexes` is not set
- Dominant language
- Python
- Stars
- 46.9k
- Forks
- 17.8k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 472
Description
### 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:**
```python
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?
- [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
Assessment
This issue has not been assessed yet.