Sapphirewhale opened a new issue, #75172:
URL: https://github.com/apache/airflow/issues/75172

   ### Under which category would you file this issue?
   
   Providers
   
   ### Apache Airflow version
   
   3.3.1
   
   ### What happened and how to reproduce it?
   
   When writing an airflow dag using a mapped task group with 
TriggerDagOperator child tasks, setting the trigger_dag_id parameter on the 
TriggerDagOperator causes a serialization error on running `airflow dags 
reserialize` (notably the DAG parses successfully).
   
   Example DAG:
   ```python
   from datetime import datetime
   
   from airflow.sdk import task_group, DAG
   from airflow.operators.trigger_dagrun import TriggerDagRunOperator
   
   with DAG(
       dag_id='expand_task_group_serialization_error',
       start_date=datetime(2026, 1, 1)
       schedule=None,
   ) as dag:
       @task_group(group_id="test_expanding_task_group")
       def trigger_one(dag_id):
           TriggerDagRunOperator(
               task_id="trigger",
               trigger_dag_id=dag_id
           )
   
       trigger_one.expand(dag_id=["dag_id_1", "dag_id_2"]
   ```
   
   Loading the above code into the airflow DAGs directory and running `airflow 
dags reserialize` throws:
   ```
   airflow.exceptions.SerializationError: Failed to serialize DAG 
'expand_task_group_serialization_error': cannot use 
'airflow.serialization.dag_dependency.DagDependency' as a set element 
(unhashable type: 'MappedArgument')
   ```
   
   ### What you think should happen instead?
   
   Airflow should not throw the above error when serializing the DAG.
   This looks to me like it's a result of the MappedArgument for trigger_dag_id 
passed from the expanded task group being used to create a DagDependency 
object. TriggerDagRunOperator.partioal(...).expand(...) seems to automatically 
handle this case, as setting the trigger_dag_id as part of the expand call 
works fine there.
   Whatever mechanism is in use there to avoid the DagDependency being created 
with an unserializable DAG ID should probably be replicated when a 
MappedArgument is passed directly to the constructor, but I wasn't able to find 
the code responsible for this.
   
   ### Operating System
   
   Red Hat Enterprise Linux
   
   ### Deployment
   
   Docker-Compose
   
   ### Apache Airflow Provider(s)
   
   standard
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-standard==1.17.0
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   Not Applicable
   
   ### Helm Chart configuration
   
   Not Applicable
   
   ### Docker Image customizations
   
   Not Applicable
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] 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)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to