mermaid: Unable to render rich display Diagram error not found.
Description
When editing MermaidJS in GitHub markdown I am finding Mermaid is often failing without giving an error message, making it difficult to find where the problem is.
This seems like something that needs to be fixed / improved otherwise debugging graphs is difficult.
Steps to reproduce
From my repo: https://github.com/HariSekhon/Diagrams-as-Code
Here is what I created:
%%{ init: {
'logLevel': 'debug',
'theme': 'dark',
'mainBranchName': 'main',
'themeVariables': {
'git0': 'red',
'git1': 'blue ',
'git2': 'green',
'gitInv0': '#FFFFFF',
'gitBranchLabel0': '#FFFFFF',
'commitLabelColor': '#FFFFFF'
}
}
}%%
gitGraph
branch staging
branch production
checkout main
commit id: "commit 1"
checkout staging
commit id: "commit 1 "
checkout production
commit id: "commit 1 "
checkout main
commit id: "commit 2"
checkout staging
commit id: "commit 2 "
checkout production
commit id: "commit 2 "
checkout main
commit id: "commit 3"
checkout staging
merge main id: "fast-forward merge" tag: "CI/CD + QA Tests"
checkout production
merge staging id: "fast-forward merge " tag: "Production Release (CI/CD)"
checkout main
commit id: "commit 4"
checkout staging
commit id: "commit 4 "
checkout production
commit id: "commit 4 "
checkout main
commit id: "commit 5"
checkout staging
commit id: "commit 5 "
checkout production
commit id: "commit 5 "
checkout main
commit id: "commit 6"
checkout staging
merge main id: "fast-forward merge 2" tag: "CI/CD + QA Tests"
checkout production
merge staging id: "fast-forward merge 2 " tag: "Production Releease (CI/CD)"
checkout main
commit id: "commit 7"
checkout staging
commit id: "commit 7 "
checkout production
commit id: "commit 7 "
checkout main
commit id: "commit 8"
checkout staging
commit id: "commit 8 "
checkout production
commit id: "commit 8 "
checkout main
commit id: "commit 9"
checkout staging
merge main id: "fast-forward merge 3" tag: "CI/CD + QA Tests"
checkout production
merge staging id: "fast-forward merge 3 " tag: "Production Release (CI/CD)"
and when I change the init mainBranchName
field to dev
and update all branch references from main
to dev
, I get a very generic error with no line number, leaving me to scour every character in 100 lines of code:
Unable to render rich display
Diagram error not found.
%%{ init: {
'logLevel': 'debug',
'theme': 'dark',
'mainBranchName': 'dev',
'themeVariables': {
'git0': 'red',
'git1': 'blue ',
'git2': 'green',
'gitInv0': '#FFFFFF',
'gitBranchLabel0': '#FFFFFF',
'commitLabelColor': '#FFFFFF'
}
}
}%%
gitGraph
branch staging
branch production
checkout dev
commit id: "commit 1"
checkout staging
commit id: "commit 1 "
checkout production
commit id: "commit 1 "
checkout dev
commit id: "commit 2"
checkout staging
commit id: "commit 2 "
checkout production
commit id: "commit 2 "
checkout dev
commit id: "commit 3"
checkout staging
merge dev id: "fast-forward merge" tag: "CI/CD + QA Tests"
checkout production
merge staging id: "fast-forward merge " tag: "Production Release (CI/CD)"
checkout dev
commit id: "commit 4"
checkout staging
commit id: "commit 4 "
checkout production
commit id: "commit 4 "
checkout dev
commit id: "commit 5"
checkout staging
commit id: "commit 5 "
checkout production
commit id: "commit 5 "
checkout dev
commit id: "commit 6"
checkout staging
merge dev id: "fast-forward merge 2" tag: "CI/CD + QA Tests"
checkout production
merge staging id: "fast-forward merge 2 " tag: "Production Releease (CI/CD)"
checkout dev
commit id: "commit 7"
checkout staging
commit id: "commit 7 "
checkout production
commit id: "commit 7 "
checkout dev
commit id: "commit 8"
checkout staging
commit id: "commit 8 "
checkout production
commit id: "commit 8 "
checkout dev
commit id: "commit 9"
checkout staging
merge dev id: "fast-forward merge 3" tag: "CI/CD + QA Tests"
checkout production
merge staging id: "fast-forward merge 3 " tag: "Production Release (CI/CD)"
The diff between the two graph codes seems pretty clean on diff:
4c4
< 'mainBranchName': 'main',
---
> 'mainBranchName': 'dev',
20c20
< checkout main
---
> checkout dev
29c29
< checkout main
---
> checkout dev
38c38
< checkout main
---
> checkout dev
42c42
< merge main id: "fast-forward merge" tag: "CI/CD + QA Tests"
---
> merge dev id: "fast-forward merge" tag: "CI/CD + QA Tests"
48c48
< checkout main
---
> checkout dev
57c57
< checkout main
---
> checkout dev
66c66
< checkout main
---
> checkout dev
70c70
< merge main id: "fast-forward merge 2" tag: "CI/CD + QA Tests"
---
> merge dev id: "fast-forward merge 2" tag: "CI/CD + QA Tests"
76c76
< checkout main
---
> checkout dev
85c85
< checkout main
---
> checkout dev
94c94
< checkout main
---
> checkout dev
98c98
< merge main id: "fast-forward merge 3" tag: "CI/CD + QA Tests"
---
> merge dev id: "fast-forward merge 3" tag: "CI/CD + QA Tests"
so I can’t see why this doesn’t work.
Is MermaidJS sensitive to whitespace?
I’ve even eliminated whitespace difference that I could see with cat -e
on Mac and verified this via:
$ diff code1.txt code2.txt > /tmp/diff.txt
$ diff -w code1.txt code2.txt > /tmp/diff-ignoring-whitespace.txt
$ diff /tmp/diff.txt /tmp/diff-ignoring-whitespace.txt
<no output>
Ultimately I think MermaidJS error messages need to be improved to give accurate feedback of why the code doesn’t work.
In the Live Editor I get this error:
Error: Trying to checkout branch which is not yet created. (Help try using "branch dev")
Eventually I’ve found the problem being that mainBranchName
was being ignored because it wasn’t wrapped in 'gitGraph': {}
.
This was harder to find than it should have been, and also any tiny mistake such as missing a comma after 'gitGraph': {}
becomes difficult to find without an error message and line number, in this case you’re squinting at 100 lines looking for any character out place…
Screenshots
See above
Code Sample
See above
Setup
- Mermaid version: whatever GitHub uses
- Browser and Version: Chrome
Additional Context
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 23 (1 by maintainers)
Commits related to this issue
- Add Rails Mermaid ERD gem and generated ERD diagram Why these changes are being introduced: EngX has been discussing ways to add more visual documentation to our applications. The Rails Mermaid ERD ... — committed to MITLibraries/thing by jazairi 10 months ago
- Add Rails Mermaid ERD gem Why these changes are being introduced: EngX has been discussing ways to add more visual documentation to our applications. The Rails Mermaid ERD gem is one way to achieve ... — committed to MITLibraries/thing by jazairi 10 months ago
- Add Rails Mermaid ERD gem Why these changes are being introduced: EngX has been discussing ways to add more visual documentation to our applications. The Rails Mermaid ERD gem is one way to achieve ... — committed to MITLibraries/thing by jazairi 10 months ago
- Add Rails Mermaid ERD gem Why these changes are being introduced: EngX has been discussing ways to add more visual documentation to our applications. The Rails Mermaid ERD gem is one way to achieve ... — committed to MITLibraries/thing by jazairi 10 months ago
- Add Rails Mermaid ERD gem Why these changes are being introduced: EngX has been discussing ways to add more visual documentation to our applications. The Rails Mermaid ERD gem is one way to achieve ... — committed to MITLibraries/thing by jazairi 10 months ago
- Add Rails Mermaid ERD gem Why these changes are being introduced: EngX has been discussing ways to add more visual documentation to our applications. The Rails Mermaid ERD gem is one way to achieve ... — committed to MITLibraries/thing by jazairi 10 months ago
- Add Rails Mermaid ERD gem Why these changes are being introduced: EngX has been discussing ways to add more visual documentation to our applications. The Rails Mermaid ERD gem is one way to achieve ... — committed to MITLibraries/thing by jazairi 10 months ago
- Add Rails Mermaid ERD gem Why these changes are being introduced: EngX has been discussing ways to add more visual documentation to our applications. The Rails Mermaid ERD gem is one way to achieve ... — committed to MITLibraries/thing by jazairi 10 months ago
- Add Rails Mermaid ERD gem Why these changes are being introduced: EngX has been discussing ways to add more visual documentation to our applications. The Rails Mermaid ERD gem is one way to achieve ... — committed to MITLibraries/thing by jazairi 10 months ago
- add quotes per https://github.com/mermaid-js/mermaid/issues/4388#issuecomment-1802802201 — committed to cal-itp/data-infra by lauriemerrell 7 months ago
- add quotes per https://github.com/mermaid-js/mermaid/issues/4388#issuecomment-1802802201 — committed to cal-itp/data-infra by lauriemerrell 7 months ago
- Add diagram showing RBAC/security for Payments dashboards (#3125) * add diagram showing rbac/security for payments dashboards * add quotes per https://github.com/mermaid-js/mermaid/issues/4388#iss... — committed to cal-itp/data-infra by lauriemerrell 7 months ago
- Invoke Prod Release (#3158) * Fix failing test on fct monthly routes (#2892) * refactor to address failing test and some docs * fix docs to reflect updated join * remove unused column * d... — committed to cal-itp/data-infra by SorenSpicknall 7 months ago
- attempt fix for GitHub mermaid render issue source: https://github.com/mermaid-js/mermaid/issues/4388 — committed to CRJFisher/code-charter by CRJFisher 5 months ago
+1 from me. It’s annoying that VS Code extension previews work perfectly on content, then you push to Github and see the red error box.
I was able to work around the issue by adding some quotes. around text block and removing embedded markdown.
yes i encountered this issue in my repo, is it still not fixed
Diagram error not found.
this error has been fixed in our newer releases (Github is few release behind). But I do agree that the error messages could be more helpful.It also doesn’t like any dashes
-
or underscores_
in ids.What was happening to me is that I was using markdown syntax without the quotes:
Minimum Example:
With quotes
flowchart TD
A["💠"]
Without quotes
flowchart TD
A[💠]
Good to know, thanks!
I’ll leave this open for people to find until the fix is live on GitHub, at which time the above should show a more specific error message.
I was encountering the same phenomenon, but by taking the above measures, I was able to solve the problem! Thank you very much!
I was able to work-around my issue by writing different Mermaid syntax, e.g.
instead of
And wrapping names that include a newline in " quotes.
I believe this is due to Github rendering with an earlier version of Mermaid (version 9 instead of the latest?) and so it’s not the Mermaid project we need to complain to… perhaps here?
https://github.com/orgs/community/discussions/70672
See also:
https://github.com/github/docs/blob/02309ab97a85d21018f872fd3c72de199a2633c7/content/repositories/working-with-files/using-files/working-with-non-code-files.md#displaying-mermaid-files-on--data-variablesproductprodname_dotcom-
Mermaid js does not like the string
self
appearing in a label for a node:vs
This took ages to figure out by basically bisecting my diagram then changing things until the error went away.
Raised as https://github.com/mermaid-js/mermaid/issues/5317
As of this writing I am facing this issue with an ER Diagram. It works fine with live editor. I created a very simple mmd file called test.mmd to display mermaid version and throws the error. From what I understand it should show the mermaid version github is using to render but it just errors out.
thanks, bud
Sure this commit fixed my issue and the mermaid displayed in github after that.
+1 still not working