Skip to content

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

@MFirulik

Description

@MFirulik

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):

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corekind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yetpriority:mediumBug that should be fixed before next release but would not block a release

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions