apache / apache/airflow

Possibility to delete all xcoms associated to a dag run using XCom.delete() function.

Open
#57,812 6 comments 0 reactions 0 assignees View on GitHub
area:core kind:feature
Dominant language
Python
Stars
46.9k
Forks
17.8k
Avg merge
2d 10h
Merged PRs (30d)
483

Description

### Description

Presently Xcom.delete() requires 'dag_id', 'run_id', 'task_id' and 'key' arguments to delete an xcom entry and if 'task_id' and 'key' are missing then we get the following error:

```
XCom.delete(dag_id=dag_run.dag_id, run_id=dag_run.run_id)
TypeError: BaseXCom.delete() missing 2 required positional arguments: 'key' and 'task_id'
```

Since its not possible to delete xcoms by directly manipulating the metadata database from tasks in airflow 3 ([50415](https://github.com/apache/airflow/discussions/50415)). Ability to delete xcoms using only the dag_id and run_id in the Xcom.delete() function will make possible the usecase to delete all xcoms associated to a dag run.

### Use case/motivation

Delete all xcoms entries for a dag run via listeners on dag completion.

### Related issues

_No response_

### Are you willing to submit a PR?

- [ ] 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 XCom.delete() and the BaseXCom.delete() signature shown in the error, then inspect the existing deletion behavior and related tests. The change is done when callers can delete all XCom entries for a dag run using only dag_id and run_id, while existing single-entry deletion remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.