Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: linkStyle can't specify IDs that don't exist at the point in the diagram #3251

Closed
Yash-Singh1 opened this issue Jul 22, 2022 · 2 comments · Fixed by #4934
Closed

Bug: linkStyle can't specify IDs that don't exist at the point in the diagram #3251

Yash-Singh1 opened this issue Jul 22, 2022 · 2 comments · Fixed by #4934
Assignees
Labels
Area: Development Graph: Flow Status: Approved Is ready to be worked on Type: Bug / Error Something isn't working or is incorrect

Comments

@Yash-Singh1
Copy link
Member

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

If I try to specify a linkstyle with a id that exists after the current linkStyle, Mermaid.js throws an error.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://mermaid.live/edit#pako:eNo1js0KwjAQhF8l7Lk9eI1QUPQJ6jGXpbu1wfyUdHMIpe_uijqnge9jmB2mTAwWngXXxTyuLhlN8Ok1SgtsTob8tgZsNuXE5y--mL4fjLrQQeQS0ZNO7B_oQBaO7MBqJZ6xBnHg0qFqXQmF7-QlF7Azho07wCp5bGkCK6XyX7p51EfxZx1vfqY3UQ
  2. Notice error

Expected behavior
A clear and concise description of what you expected to happen.

linkStyles are applied after.

Screenshots
If applicable, add screenshots to help explain your problem.

Code Sample
If applicable, add the code sample or a link to the live editor.

https://mermaid.live/edit#pako:eNo1js0KwjAQhF8l7Lk9eI1QUPQJ6jGXpbu1wfyUdHMIpe_uijqnge9jmB2mTAwWngXXxTyuLhlN8Ok1SgtsTob8tgZsNuXE5y--mL4fjLrQQeQS0ZNO7B_oQBaO7MBqJZ6xBnHg0qFqXQmF7-QlF7Azho07wCp5bGkCK6XyX7p51EfxZx1vfqY3UQ

Versions: mermaid.live v9.1.3

Additional context
Add any other context about the problem here.

N/a

@Yash-Singh1 Yash-Singh1 added Type: Bug / Error Something isn't working or is incorrect Status: Approved Is ready to be worked on Graph: Flow Area: Development labels Jul 22, 2022
@github-actions github-actions bot added the Status: Triage Needs to be verified, categorized, etc label Jul 22, 2022
@Yash-Singh1 Yash-Singh1 removed the Status: Triage Needs to be verified, categorized, etc label Jul 22, 2022
@RounakJoshi09
Copy link
Contributor

RounakJoshi09 commented Oct 8, 2023

Hi @Yash-Singh1 @nirname ,

I hope all is well. While investigating a particular bug, I noticed an issue with how linkStyle functions when applied to non-existent links. after reading the documentation , I found out that linkStyles applies on links in 0-indexed fashion. So, in this code
linkStyle 1 display:none; A --> B
we are applying linkStyle to the second link (according to 0-indexed) which doesnot even exists. This results in an unclear error message: TypeError: Cannot set properties of undefined (setting 'style').

The error message doesn't effectively communicate the underlying issue to the user.
Could you please assign this issue to me? Additionally, would it be possible to generate a more descriptive error message for such cases to enhance user experience?

Thank you for your time and consideration. I'm looking forward to your response.

Best regards,
Rounak

@Yash-Singh1
Copy link
Member Author

Could you please assign this issue to me?

Done

Additionally, would it be possible to generate a more descriptive error message for such cases to enhance user experience?

Yes, that would be possible by throwing a parse error. Here is an example

let error = new Error('Incorrect usage of "merge". Cannot merge a branch to itself');
error.hash = {
text: 'merge ' + otherBranch,
token: 'merge ' + otherBranch,
line: '1',
loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
expected: ['branch abc'],
};
throw error;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Development Graph: Flow Status: Approved Is ready to be worked on Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants