Skip to content

Nested task group names are not generated properly #41596

Closed

Description

@jerryqhyu

Apache Airflow version

2.9.3

If "Other Airflow 2 version" selected, which one?

No response

What happened?

When the same task group gets called multiple times within a task group, a airflow.exceptions.DuplicateTaskIdFound is raised. See print_k_group_inner in the following example. Note that if you comment out one of the print_k_group_inner, the top-level task groups are named correctly to print_k_group and print_k_group__1.

What you think should happen instead?

There should be 4 task groups created and no errors raised.

-print_k_group.print_k_group_inner
-print_k_group.print_k_group_inner__1
-print_k_group__1.print_k_group_inner
-print_k_group__1.print_k_group_inner__1

How to reproduce

from airflow.decorators import dag, task_group, task
from pendulum import datetime


@dag(
    start_date=datetime(2023, 7, 1),
    schedule=None,
    catchup=False,
    tags=["@task_group", "dependencies"],
)
def test_tg():
    @task
    def get_k():
        return 10

    @task
    def print_k(k):
        print(k)

    @task_group
    def print_k_group(k):
        print_k_group_inner(k)
        print_k_group_inner(k)

    @task_group
    def print_k_group_inner(k):
        print_k(k)

    k = get_k()
    print_k_group(k)
    print_k_group(k)


test_tg()

Operating System

Ubuntu 22.04.4 LTS

Versions of Apache Airflow Providers

None

Deployment

Official Apache Airflow Helm Chart

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. boring-cyborg commented on Aug 19, 2024

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

  2. removed
    needs-triagelabel for new issues that we didn't triage yet
    on Jan 10, 2025
  3. isaiahiruoha commented on Jul 25, 2025

    @isaiahiruoha
    Contributor

    Update 2025, reproduced in version 2.11.0, fixed in version 3.0.0

  4. eladkal commented on Jul 27, 2025

    @eladkal
    Contributor

    Update 2025, reproduced in version 2.11.0, fixed in version 3.0.0

    So you were unable to reproduce on 3.x?

  5. isaiahiruoha commented on Jul 27, 2025

    @isaiahiruoha
    Contributor

    Correct, on version 3.x the same DAG functions correctly with the expected nested naming instead of throwing DuplicateTaskIdFound.

  6. eladkal commented on Jul 27, 2025

    @eladkal
    Contributor

    Closing as fixed

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions