Skip to content

airflow dags show Exception: "The node ... should be TaskGroup and is not" #23315

Description

@MatrixManAtYrService

Apache Airflow version

main (development)

What happened

This happens for any dag with a task expansion. For instance:

from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator

with DAG(
    dag_id="simple_mapped",
    start_date=datetime(1970, 1, 1),
    schedule_interval=None,
) as dag:

    BashOperator.partial(task_id="hello_world").expand(
        bash_command=["echo hello", "echo world"]
    )

I ran airflow dags show simple_mapped and instead of graphviz DOT notation, I saw this:

{dagbag.py:507} INFO - Filling up the DagBag from /Users/matt/2022/04/27/dags
Traceback (most recent call last):
  File .../bin/airflow", line 8, in <module>
    sys.exit(main())
  File ... lib/python3.9/site-packages/airflow/__main__.py", line 38, in main
    args.func(args)
  File ... lib/python3.9/site-packages/airflow/cli/cli_parser.py", line 51, in command
    return func(*args, **kwargs)
  File ... lib/python3.9/site-packages/airflow/cli/commands/dag_command.py", line 205, in dag_show
    dot = render_dag(dag)
  File ... lib/python3.9/site-packages/airflow/utils/dot_renderer.py", line 188, in render_dag
    _draw_nodes(dag.task_group, dot, states_by_task_id)
  File ... lib/python3.9/site-packages/airflow/utils/dot_renderer.py", line 125, in _draw_nodes
    _draw_task_group(node, parent_graph, states_by_task_id)
  File ... lib/python3.9/site-packages/airflow/utils/dot_renderer.py", line 110, in _draw_task_group
    _draw_nodes(child, parent_graph, states_by_task_id)
  File ... lib/python3.9/site-packages/airflow/utils/dot_renderer.py", line 121, in _draw_nodes
    raise AirflowException(f"The node {node} should be TaskGroup and is not")
airflow.exceptions.AirflowException: The node <Mapped(BashOperator): hello_world> should be TaskGroup and is not

What you think should happen instead

I should see something about the dag structure.

How to reproduce

run airflow dags show for any dag with a task expansion

Operating System

MacOS, venv

Versions of Apache Airflow Providers

n/a

Deployment

Virtualenv installation

Deployment details

❯ airflow version                
2.3.0.dev0

cloned at 4f6fe72

Anything else

There's a related card on this board https://github.com/apache/airflow/projects/12

Support Mapped task groups in the DAG "dot renderer" (i.e. backfill job with --show-dagrun)

But I don't think that functionality is making it into 2.3.0, so maybe we need to add a fix here in the meantime?

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

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