apache / apache/airflow

Branch task does not prevent non-selected downstream tasks from running in TaskGroup (Airflow 3.2.x)

Open
#65,745 7 comments 2 reactions 0 assignees View on GitHub
area:core kind:bug needs-triage priority:medium
Dominant language
Python
Stars
46.9k
Forks
17.8k
Avg merge
2d 9h
Merged PRs (30d)
472

Description

### Under which category would you file this issue?

Providers

### Apache Airflow version

3.2.0 (also reproduced on 3.2.1)

### What happened and how to reproduce it?

Branching inside a TaskGroup does not reliably prevent non-selected downstream tasks from running.
Even when branch callable returns a specific task_id, sibling downstream tasks still get scheduled/run.
In our production setup (KubernetesExecutor), this causes unnecessary pod starts and resource waste.

Minimal example (TaskFlow + TaskGroup + branch):
```python
from airflow.sdk import DAG, task, task_group
from airflow.providers.standard.operators.empty import EmptyOperator
from airflow.sdk.bases.operator import chain
from pendulum import datetime
with DAG(
dag_id="repro_branch_taskgroup_32x",
start_date=datetime(2026, 1, 1),
schedule=None,
catchup=False,
):
@task_group(group_id="g")
def g():
@task.branch(task_id="choose")
def choose():
return "g.path_a"
@task(task_id="path_a")
def path_a():
print("A")
@task(task_id="path_b")
def path_b():
print("B should be skipped")
end = EmptyOperator(task_id="end")
c = choose()
a = path_a()
b = path_b()
chain(c, [a, b], end)
g()
```

### What you think should happen instead?

Only selected downstream branch task(s) should run.
All non-selected downstream tasks should be marked skipped before execution.

### Operating System

_No response_

### Deployment

Official Apache Airflow Helm Chart

### Apache Airflow Provider(s)

_No response_

### Versions of Apache Airflow Providers

_No response_

### Official Helm Chart version

1.18.0

### Kubernetes Version

v1.32.4

### Helm Chart configuration

_No response_

### Docker Image customizations

_No response_

### Anything else?

**Environment**
Executor: KubernetesExecutor
Python: 3.13
Deployment: Docker/Kubernetes
DAG contains TaskGroup and mapped workloads in real case

### Are you willing to submit 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

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.