tirkarthi commented on issue #48670:
URL: https://github.com/apache/airflow/issues/48670#issuecomment-2772366976

   Thanks, I can reproduce this. The first dagrun completes for the v1 version 
and on clearing with v2 version the the task instance for the second run 
becomes removed but the second task instance which points to v2 version is 
still taken up whose serialized data is used that won't contain `bye_task` . A 
fix I can think of would be to skip the task instance if it's in removed state.
   
   
   ```patch
   diff --git a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py 
b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py
   index e15a39d4d9..9d76eaff98 100644
   --- a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py
   +++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py
   @@ -55,6 +55,7 @@ from airflow.api_fastapi.core_api.services.ui.grid import (
    )
    from airflow.models import DagRun, TaskInstance
    from airflow.models.taskinstancehistory import TaskInstanceHistory
   +from airflow.utils.state import TaskInstanceState
    
    grid_router = AirflowRouter(prefix="/grid", tags=["Grid"])
    
   @@ -162,8 +163,8 @@ def grid_data(
            run_dag = tis[0].dag_version.serialized_dag.dag
            task_node_map = get_task_group_map(dag=run_dag)
            for ti in tis:
   -            # Skip the Task Instances if upstream/downstream filtering is 
applied
   -            if task_node_map_exclude and ti.task_id not in 
task_node_map_exclude:
   +            # Skip the Task Instances if upstream/downstream filtering is 
applied or task instance is in removed state
   +            if task_node_map_exclude and ti.task_id not in 
task_node_map_exclude or ti.state == TaskInstanceState.REMOVED:
                    continue
    
                # Populate the Grouped Task Instances (All Task Instances 
except the Parent Task Instances)
   
   ```


-- 
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