Apache Airflow version
2.3.3 (latest released)
What happened
Airflow set default task group while creating operator if dag parameter is set
https://github.com/apache/airflow/blob/main/airflow/models/baseoperator.py#L236
However, It doesn't set the default task group while adding a task using dag.add_task function
https://github.com/apache/airflow/blob/main/airflow/models/dag.py#L2179
This broke the code at line no
https://github.com/apache/airflow/blob/main/airflow/models/taskmixin.py#L312 and getting the error Cannot check for mapped dependants when not attached to a DAG.
Please add below line in dag.add_task function also:
if dag:
task_group = TaskGroupContext.get_current_task_group(dag)
if task_group:
task_id = task_group.child_id(task_id)
What you think should happen instead
It should not break if task is added using dag.add_task
How to reproduce
don't dag parameter while creating operator object. add task using add_task in dag.
Operating System
Any
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
Code of Conduct
Apache Airflow version
2.3.3 (latest released)
What happened
Airflow set default task group while creating operator if dag parameter is set
https://github.com/apache/airflow/blob/main/airflow/models/baseoperator.py#L236
However, It doesn't set the default task group while adding a task using dag.add_task function
https://github.com/apache/airflow/blob/main/airflow/models/dag.py#L2179
This broke the code at line no
https://github.com/apache/airflow/blob/main/airflow/models/taskmixin.py#L312 and getting the error Cannot check for mapped dependants when not attached to a DAG.
Please add below line in dag.add_task function also:
if dag:
task_group = TaskGroupContext.get_current_task_group(dag)
if task_group:
task_id = task_group.child_id(task_id)
What you think should happen instead
It should not break if task is added using dag.add_task
How to reproduce
don't dag parameter while creating operator object. add task using add_task in dag.
Operating System
Any
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
Code of Conduct