-
Notifications
You must be signed in to change notification settings - Fork 615
Open
Description
Summary
ELK algorithms other than layered panic with "index out of range" when an edge connects an external node to a node inside a nested container.
Reproduction
d2 --version
0.7.1test.d2:
outer: {
inner: {
a
}
}
external -> outer.inner.aWorking:
❯ d2 --layout=elk --elk-algorithm=layered test.d2 test.png
success: successfully compiled test.d2 to test.png in 372.446125msError:
d2 --layout=elk --elk-algorithm=stress test.d2 test.png
panic: runtime error: index out of range [0] with length 0
goroutine 8 [running]:
oss.terrastruct.com/d2/d2layouts/d2elklayout.Layout(...)
oss.terrastruct.com/d2/d2layouts/d2elklayout/layout.go:604 +0x1dccRoot Cause
d2/d2layouts/d2elklayout/layout.go
Lines 601 to 605 in 93f9720
| points := edge.Route | |
| startIndex, endIndex := 0, len(points)-1 | |
| start := points[startIndex] | |
| end := points[endIndex] |
Non-layered ELK algorithms return empty Route arrays for edges that cross container boundaries. The code assumes edge.Route is non-empty.
AI Disclaimer
Issue diagnosed with assistance from Claude 4.5 Opus.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
No status