pedro-cf opened a new issue, #67714:
URL: https://github.com/apache/airflow/issues/67714

   ### Under which category would you file this issue?
   
   Providers
   
   ### Apache Airflow version
   
   3.2.2
   
   ### What happened and how to reproduce it?
   
   
   ### What happened
   
   Graph View renders incorrectly when a `@task_group` returns task references 
and **internal tasks inside the group** are wired directly to a **downstream 
task outside the group**, in addition to a normal exit/join path.
   
   Observed symptoms:
   
   - TaskGroup layout is misaligned (e.g. vertical stacking instead of 
left-to-right flow)
   - Dependency edges cross/overlap the TaskGroup boundary in confusing ways 
(wrap-around lines)
   - Internal task dependencies inside the group may not render clearly
   
   The DAG **executes correctly**. This is a **Graph View rendering/layout 
issue only**.
   
   ### Minimal reproduction
   
   Below is a minimal DAG. With only `entry` / `exit` wired across the group 
boundary, Graph View renders correctly.
   
   Adding these two lines breaks Graph View:
   
   ```python
   group_result["a2"] >> final_task_result
   group_result["a3"] >> final_task_result
   ```
   
   Full DAG:
   
   ```python
   from datetime import datetime
   
   from airflow.sdk import dag, task, task_group
   
   
   @dag(
       dag_id="taskgroup_return_render_bug_demo",
       start_date=datetime(2024, 1, 1),
       schedule=None,
       catchup=False,
   )
   def taskgroup_return_render_bug_demo():
       from airflow.task.trigger_rule import TriggerRule
   
       @task
       def start():
           return 1
   
       @task(trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS)
       def final_task():
           pass
   
       @task_group
       def group_a():
           @task
           def task_a1():
               pass
   
           @task.branch
           def branch_a():
               return [
                   "group_a.task_a2",
                   "group_a.task_a3",
               ]
   
           @task
           def task_a2():
               pass
   
           @task
           def task_a3():
               pass
   
           @task(trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS)
           def group_done():
               pass
   
           a1 = task_a1()
           branch = branch_a()
           a2 = task_a2()
           a3 = task_a3()
           done = group_done()
   
           a1 >> branch >> [a2, a3]
           [a2, a3] >> done
   
           return {
               "entry": a1,
               "branch": branch,
               "a2": a2,
               "a3": a3,
               "exit": done,
           }
   
       start_task = start()
       group_result = group_a()
       final_task_result = final_task()
   
       start_task >> group_result["entry"]
       group_result["exit"] >> final_task_result
   
       # Graph View breaks when these are present:
       group_result["a2"] >> final_task_result
       group_result["a3"] >> final_task_result
   
   
   taskgroup_return_render_bug_demo()
   ```
   
   ### Steps to reproduce
   
   1. Deploy the DAG above to Airflow 3.2.2
   2. Open **Graph View** for `taskgroup_return_render_bug_demo`
   3. Compare rendering:
      - **Works:** comment out the two `a2` / `a3` → `final_task` lines
      - **Breaks:** uncomment those two lines
   
   ### What you think should happen instead?
   
   Graph View should render TaskGroups consistently whether or not internal 
returned task references are wired to external downstream tasks.
   
   Expected behavior:
   
   - TaskGroup box layout should stay coherent ( sensible left-to-right / 
top-to-bottom flow )
   - Edges from internal tasks to external downstream tasks should route 
cleanly across the group boundary, without wrap-around or overlapping lines
   - Internal dependencies inside the TaskGroup should remain visible when the 
group is expanded
   - Rendering should match the actual dependency graph produced at parse time
   
   Since execution is already correct, Graph View should reflect the same 
structure operators see in code / Grid view, without requiring authors to avoid 
legitimate dependency patterns.
   
   ### Operating System
   
   Ubuntu 24.04.4 LTS
   
   ### Deployment
   
   Docker-Compose
   
   ### Apache Airflow Provider(s)
   
   _No response_
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   _No response_
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] 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