Skip to content

Fix panic in dagre_rust remove_edge_label_proxies on edge labels#18

Open
cetex wants to merge 1 commit into1jehuang:masterfrom
cetex:fix/dagre-edge-label-proxy-crash
Open

Fix panic in dagre_rust remove_edge_label_proxies on edge labels#18
cetex wants to merge 1 commit into1jehuang:masterfrom
cetex:fix/dagre-edge-label-proxy-crash

Conversation

@cetex
Copy link

@cetex cetex commented Jan 29, 2026

Fix panic in dagre_rust remove_edge_label_proxies on edge labels

remove_edge_label_proxies() in dagre_rust unconditionally unwraps node.e, which can be None by the time the function runs. The layout pipeline calls nesting_graph::cleanup() between inject_edge_label_proxies and remove_edge_label_proxies, which removes the nesting root node and its incident edges -- this can invalidate the edge reference stored on dummy proxy nodes.

This causes a panic on any diagram that produces edge label proxies during layout:

  • Flowcharts with edge labels (-->|label|) or diamond decision nodes ({...})
  • State diagrams with transition labels (: event)
  • ER diagrams with relationship labels

The fix replaces the unwrap() with if let Some(...), so a missing edge ref is skipped rather than crashing. The node is still removed from the graph regardless.

Includes regression tests for all three crash cases.

(I didn't do any of this, just forked the repo and asked my AI-agent do fix the bug I / we found while I worked on other stuff)

remove_edge_label_proxies() unconditionally unwraps node.e, which is
None for some edge-proxy dummy nodes by the time the function runs.
The layout pipeline calls nesting_graph::cleanup() between inject and
remove, which can invalidate the edge reference.

Replace the unwrap with `if let Some(...)` so missing edge refs are
silently skipped instead of panicking. This fixes crashes on any
diagram that uses edge labels: flowcharts with -->|label| or diamond
nodes, state diagrams with transition labels, and ER diagrams.

Adds regression tests for all three crash cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant