Skip to content

fix/task-group-branching: Allowing for relative paths to be branched to in a task group#68797

Draft
jroachgolf84 wants to merge 2 commits into
apache:mainfrom
jroachgolf84:fix/task-group-branching
Draft

fix/task-group-branching: Allowing for relative paths to be branched to in a task group#68797
jroachgolf84 wants to merge 2 commits into
apache:mainfrom
jroachgolf84:fix/task-group-branching

Conversation

@jroachgolf84

@jroachgolf84 jroachgolf84 commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR allows for the proper resolution of relative paths when branching within a Task Group.

For example, if a Task Group tg has a branching task and a task a and b, returning "a" from the branching task will result in a executing and b getting skipped. This is shown in the DAG/screenshot below.

However, if there is both a top-level a and an a in the Task Group, a will be skipped in the Task Group.

related: #65751

Testing

These changes were tested in two different ways; via unit tests, as well as E2E testing. To execute the unit tests added as part of this PR, the commands below can be run:

breeze testing providers-tests providers/standard/tests/unit/standard/operators/test_branch_operator.py

breeze testing task-sdk-tests providers/standard/tests/unit/standard/operators/test_branch_operator.py

To test these changes E2E, the DAG below was used. To ensure the changes were correct, the behavior expected would be:

  • Task a in tg executes
  • Task tg.c executes
  • Task e inside of tg executes
from airflow.sdk import DAG, task, task_group
from datetime import datetime

with DAG(
    dag_id="fix_task_group_branching",
    start_date=datetime(2026, 1, 1),
    schedule="@once"
) as dag:

    @task_group()
    def tg():

        @task.branch
        def choose_tg_relative():
            return "a"

        @task
        def a():
            # Should execute
            return None

        @task
        def b():
            # Should be skipped
            return None

        choose_tg_relative() >> [a(), b()]

        @task.branch
        def choose_tg_absolute():
            return "tg.c"

        @task
        def c():
            return None

        @task
        def d():
            return None

        choose_tg_absolute() >> [c(), d()]

    tg()
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant