mermaid icon indicating copy to clipboard operation
mermaid copied to clipboard

A certain simple graph does not render; gives error

Open rpus opened this issue 1 year ago • 1 comments

Description

Hi... This:

graph TD
  a-->b11
  subgraph b1
    subgraph b11
      subgraph b111
      end
    end
  end
  b1-->c

gives:

Cannot read properties of undefined (reading 'id')

(even in mermaid 9.4.0).

Steps to reproduce

Repro as above!

Screenshots

No response

Code Sample

// as above!

Setup

  • Mermaid version: 9.4.0
  • Browser and Version: [Chrome, Edge, Firefox]

Additional Context

Numerous other/similar case are fine btw (so these will be good to check as tests):

graph TD
  a-->b11
  subgraph b1
    subgraph b11
    end
  end
  b1-->c
graph TD
  a-->b11
  subgraph b1
    subgraph b11
      subgraph b111
      end
    end
  end
graph TD
  subgraph b1
    subgraph b11
      subgraph b111
      end
    end
  end
  b1-->c
graph TD
  a-->b11
  subgraph b1
    subgraph b11
    end
    subgraph b12
    end
  end
  b1-->c

rpus avatar Mar 08 '23 07:03 rpus

Possibly (?) related to this: https://github.com/mermaid-js/mermaid-live-editor/issues/1173

rpus avatar Mar 16 '23 11:03 rpus

Same error for the following (simpler) graphs

graph TD

a-->b1

subgraph b1
b11
end

subgraph b11
b111
end

b11-->c

Trace

View.669324eb.js:3 view fail TypeError: Cannot read properties of undefined (reading 'id')
    at index-1e7f2254.c8c71bd0.js:1:10249
    at Array.map (<anonymous>)
    at $ (index-1e7f2254.c8c71bd0.js:1:9522)
    at index-1e7f2254.c8c71bd0.js:1:9912
    at Array.map (<anonymous>)
    at $ (index-1e7f2254.c8c71bd0.js:1:9522)
    at gt (index-1e7f2254.c8c71bd0.js:1:11488)
    at Object.le [as draw] (styles-7882abfe.1296b518.js:2:1390)
    at Object.render$1 [as render] (state.f87e7922.js:87:1021)

ioggstream avatar Jul 11 '23 13:07 ioggstream

https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/dagre-wrapper/index.js#L72

nirname avatar Jul 11 '23 15:07 nirname

Closing in favor of #4644

nirname avatar Jul 16 '23 13:07 nirname