y-sudharshan opened a new pull request, #61279:
URL: https://github.com/apache/airflow/pull/61279

   Description
   This PR fixes issue #61208 where the grid view endpoint crashes with a 500 
Internal Server Error when a task is converted to a TaskGroup (or vice versa) 
between DAG versions while historical DagRuns still exist.
   
   Root Cause
   The crash occurs in the _merge_node_dicts function within the FastAPI 
service layer. When a DAG structure evolves:
   
   Historical Runs: May have a node (Task) with children=None.
   
   Current Run: May have a node (TaskGroup) with the same ID but children=[...].
   
   The recursive merge logic attempted to iterate over the None value from the 
historical run, leading to:
   
   TypeError: 'NoneType' object is not iterable.
   
   Changes Made
   Defensive Recursion: Updated _merge_node_dicts in 
airflow/api_fastapi/core_api/services/ui/grid.py to handle None values by 
defaulting to an empty list during iteration and recursive calls.
   
   Structural Flexibility: Enabled the grid view to gracefully handle ID 
collisions where a node's type changes across the DAG's lifecycle.
   
   Testing:
   
   Added 8 unit tests in tests/api_fastapi/core_api/services/ui/test_grid.py to 
validate recursive merging with mismatched types.
   
   Added a regression integration test using the minimal DAG provided in the 
issue to ensure the 500 error is resolved.
   
   Impact
   Resolves the UI crash for users refactoring DAGs into TaskGroups.
   
   Maintains backward compatibility for displaying historical runs with 
deprecated structures.
   
   Checklist
   [x] Code changes are covered with tests
   
   [x] New unit test file created for service layer testing
   
   [x] Integration test added to existing test suite
   
   [x] Code follows existing patterns and conventions
   
   [x] Passes all linting checks (ruff, pylint)
   
   [x] No breaking changes
   
   Generated-by: GitHub Copilot 
   
   Closes: #61208


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