pierrejeambrun commented on code in PR #61279:
URL: https://github.com/apache/airflow/pull/61279#discussion_r2813437550


##########
airflow-core/src/airflow/api_fastapi/core_api/services/ui/grid.py:
##########
@@ -32,15 +33,22 @@
 log = structlog.get_logger(logger_name=__name__)
 
 
-def _merge_node_dicts(current, new) -> None:
+def _merge_node_dicts(current: list[dict[str, Any]], new: list[dict[str, Any]] 
| None) -> None:
+    """Merge node dictionaries from different DAG versions, handling structure 
changes."""
+    # Handle None case - can occur when merging old DAG versions
+    # where a TaskGroup was converted to a task or vice versa
+    if new is None:
+        return
+
     current_nodes_by_id = {node["id"]: node for node in current}
     for node in new:
         node_id = node["id"]
         current_node = current_nodes_by_id.get(node_id)
         if current_node is not None:
-            # if we have children, merge those as well
-            if current_node.get("children"):
-                _merge_node_dicts(current_node["children"], 
node.get("children", []))
+            # Only merge children if current node already has children
+            # This preserves the structure of the latest DAG version
+            if current_node.get("children") is not None:
+                _merge_node_dicts(current_node["children"], 
node.get("children"))

Review Comment:
   No. This was lost in the process. 
   
   That was your first AI generated version. In between we updated that, and 
the prompt is now reverting to it's first wrong version.
   
   This is making the UI crash. Can you please keep the structure when you were 
merging if any of current_children or node_children were "None". Not when only 
the `current_children` are not None. (What if node children are not None but 
current_children are None, we don't merge anything?)
   
   Also a lot of tests were removed in the process.



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