Skip to content

[MERMAID] Shape attributes on node causes the mermaid exporter to crash #40

@john-scalingo

Description

@john-scalingo

The mermaid exporter crashes when there's a shape attribute on a node.

This is due to this code: https://github.com/emicklei/dot/blob/master/mermaid.go#L82-L84

Which expect the shape attribute to be of type shape where it can not be. This type is always string.

This can be easily reproduced with:

	graph := dot.NewGraph(dot.Directed)
	graph.Node("A").Box()
	graph.Edge(graph.Node("A"), graph.Node("B"))

	fmt.Println(dot.MermaidGraph(graph, dot.MermaidTopDown))

Which causes the following error:

panic: interface conversion: interface {} is string, not dot.shape

goroutine 1 [running]:
github.com/emicklei/dot.diagramGraph(0xc0000a8000, 0xc00007e020)
        /home/john/gocode/pkg/mod/github.com/emicklei/[email protected]/mermaid.go:83 +0xb94
github.com/emicklei/dot.diagram(0xc0000a8000, {0x4bd97a, 0x5}, 0x1)
        /home/john/gocode/pkg/mod/github.com/emicklei/[email protected]/mermaid.go:67 +0x545
github.com/emicklei/dot.MermaidGraph(...)
        /home/john/gocode/pkg/mod/github.com/emicklei/[email protected]/mermaid.go:39
main.main()
        /home/john/Documents/dotbug/test.go:14 +0x3b9
exit status 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions