mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.52k stars 240 forks source link

"Cannot read properties of undefined (reading 'config')" Exception caused by click events #789

Open phil-flip opened 1 week ago

phil-flip commented 1 week ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Create a Mermaid flowchart diagram-file (.md/.mmd) with a link.

    flowchart TB
    subgraph site
        subgraph server
            db-PSQL-[(PostgreSQL)]
            app-NFS[/NFS Share/]
            app-Samba[/"Samba - This will break"/]
            app-OLDAP[/OpenLDAP/]
            app-SSH[/SSH/]
        end
    end
    
    %%This causes the exception
    click app-Samba "https://example.com"
    
    subgraph oldDC?
        app-oldDC[/Old SAMBA/]
    end
    
    app-OLDAP --> app-oldDC
  2. Create a config file with the elk renderer enabled
    {
    "theme": "dark",
    "flowchart": {
        "defaultRenderer": "elk",
        "htmlLabels": true
    }
    }
  3. Render it: mmdc --configFile "config.json" -i "input.mmd" -o "output.png"

--> Exception:

TypeError: Cannot read properties of undefined (reading 'config')
insertNode (C:\Users\REDACTED\AppData\Roaming\npm\node_modules\@mermaid-js\mermaid-cli\node_modules\mermaid\dist\mermaid.js:47367:25)
addVertex (file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/dist/index.html:1046:1345)
file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/dist/index.html:1046:1607
Array.map (<anonymous>)
addVertices (file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/dist/index.html:1046:1586)
    at #evaluate (file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/ExecutionContext.js:388:19)
    at async ExecutionContext.evaluate (file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/ExecutionContext.js:275:16)
    at async IsolatedWorld.evaluate (file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/IsolatedWorld.js:97:16)
    at async CdpJSHandle.evaluate (file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/api/JSHandle.js:146:20)  
    at async CdpElementHandle.evaluate (file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandle.js:340:20)
    at async CdpElementHandle.$eval (file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandle.js:494:24)
    at async CdpFrame.$eval (file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/api/Frame.js:448:20)
    at async CdpPage.$eval (file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.js:450:20)
    at async renderMermaid (file:///C:/Users/REDACTED/AppData/Roaming/npm/node_modules/@mermaid-js/mermaid-cli/src/index.js:250:22)
    at render (C:\Users\REDACTED\AppData\Roaming\npm\node_modules\@mermaid-js\mermaid-cli\node_modules\mermaid\dist\mermaid.js:54828:30)

The issue points to the following section in the mermaid package.

I believe that renderOptions.config is not being set, and causes the code to fail.

Desktop:

Additional context I tried setting securityLevel int eh config, but that didn't work, but worth looking into again.