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

Error with diagramsnet, when using parameters #1602

Closed
Heiss opened this issue Jul 28, 2023 · 4 comments · Fixed by #1609
Closed

Error with diagramsnet, when using parameters #1602

Heiss opened this issue Jul 28, 2023 · 4 comments · Fixed by #1609

Comments

@Heiss
Copy link
Contributor

Heiss commented Jul 28, 2023

Hey,

as i mentioned here, i got an error when using a parameter in addition with diagramsnet.

Example:
I created a diagram with diagrams.net online editor:
image

The following url (generated by https://kroki.io/#how)

http://localhost:8080/diagramsnet/svg/
eNp1U11v2kAQfOdXrO4pkYrtM8ZAiJESIkGbkFYxKhVvV_vAR84-53wOmF_f9UeDIrXyg3dvbtc7M-vb9LQTkkOiChMQludWLNhes7SwMm4IpCoWO8HjgLiOO-g7o747XjvjG-reeL418eiWANvzDItX6iykZPbQcuBqI7JYHQt4XgN1LGcKeOB7Uzj53jXc5bnkG_77URh7OBhZAx-uHpfr1dMXkOKVw4JHr-oa5olWKbcp9SynfiBkO6ZFV0KAG7YPyGb-8EwXx8PbbrTcVZPkPvqaEHjnuhAqw7Gp5VtDAqbKeUBi_i4iTmY9gNuOKGQsReQHsuhTAgKprr95i3DklueXstxGg7s3JwybGqxKTwvN8mSlYi4hPtW6-B6BuAoIdSbYYK_rFl0QijOvAcxKEfOiAYxS0oi8TSKVZTwyTcy0Rs2acKdk2yXHuT6CMGLykm1EbJKAjIdOmy-52Cd1J-rgScpqEIMiYWhFHbYUkIRWyvxNGk5zLmVDHe_b_0aaj-rG6f9fekrv5w-HX7L46Y3z7eGl8r_Tvot2MFni4Eu8p2CjtIxxLlPVZLQqsxgXzJkeE2F4mLOIB0fUeJqYVAZ02php-OnTCJRcBmhd4bgrRleA9wY-ToiGDAf4PrYqURfjpFOoxhkKve-KPvOxW0IfatkXuWrs4n-zRna3R7NeDdY_06z3B2oZ9vY=

is working as expected and returns

<svg xmlns="http://www.w3.org/2000/svg" style="left: 0px; top: 0px; width: 100%; height: 100%; display: block; min-width: 122px; min-height: 62px;"><g><g/><g><g transform="translate(0.5,0.5)" style="visibility: visible;"><rect x="1" y="1" width="120" height="60" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/></g><g style=""><g><foreignObject pointer-events="none" width="100%" height="100%" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 31px; margin-left: 2px;"><div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Hello World</div></div></div></foreignObject></g></g></g><g/><g/></g></svg>

But if i add a query-parameter to the same url:

http://localhost:8080/diagramsnet/svg/
eNp1U11v2kAQfOdXrO4pkYrtM8ZAiJESIkGbkFYxKhVvV_vAR84-53wOmF_f9UeDIrXyg3dvbtc7M-vb9LQTkkOiChMQludWLNhes7SwMm4IpCoWO8HjgLiOO-g7o747XjvjG-reeL418eiWANvzDItX6iykZPbQcuBqI7JYHQt4XgN1LGcKeOB7Uzj53jXc5bnkG_77URh7OBhZAx-uHpfr1dMXkOKVw4JHr-oa5olWKbcp9SynfiBkO6ZFV0KAG7YPyGb-8EwXx8PbbrTcVZPkPvqaEHjnuhAqw7Gp5VtDAqbKeUBi_i4iTmY9gNuOKGQsReQHsuhTAgKprr95i3DklueXstxGg7s3JwybGqxKTwvN8mSlYi4hPtW6-B6BuAoIdSbYYK_rFl0QijOvAcxKEfOiAYxS0oi8TSKVZTwyTcy0Rs2acKdk2yXHuT6CMGLykm1EbJKAjIdOmy-52Cd1J-rgScpqEIMiYWhFHbYUkIRWyvxNGk5zLmVDHe_b_0aaj-rG6f9fekrv5w-HX7L46Y3z7eGl8r_Tvot2MFni4Eu8p2CjtIxxLlPVZLQqsxgXzJkeE2F4mLOIB0fUeJqYVAZ02php-OnTCJRcBmhd4bgrRleA9wY-ToiGDAf4PrYqURfjpFOoxhkKve-KPvOxW0IfatkXuWrs4n-zRna3R7NeDdY_06z3B2oZ9vY=?id=testref

it returns

Error 400; Internal server error

I would expect, that it ignores the parameter and returns the same data as before.
I hope, my example clarifies the error. Thank you for your support.

Heiss

@Heiss
Copy link
Contributor Author

Heiss commented Aug 2, 2023

I am trying to fix it on my own and tinker a little bit...

I found out with some print statements in this file

return micro.send(res, 200, output)
that the diagrams.net part gets and returns as expected (it gets xml stuff and returns svg stuff).
But the kroki server returns 400. So i am guessing, there is an error in the communication with between diagramsnet java component and diagramsnet javascript component.

It seems to me as an easy fix, if i would know the whole system. But i do not know how to debug this websocket stuff. Maybe you can give me some hints.

@Heiss Heiss closed this as completed Aug 2, 2023
@Heiss Heiss reopened this Aug 2, 2023
@ggrossetie
Copy link
Member

I believe that the root cause is: https://github.com/yuzutech/kroki/blob/main/diagrams.net/src/index.js#L17

The regular expression asserts that the URL must end with svg or png but when there's an option it will end with ?opt=value.

@ggrossetie
Copy link
Member

You can take a look at how we handle things on the Mermaid service:
https://github.com/yuzutech/kroki/blob/main/mermaid/src/index.js#L28-L29

@Heiss
Copy link
Contributor Author

Heiss commented Aug 2, 2023

Hey, that was easy. I think this issue was there with mermaid, too. So i copied the workaround from there. In the local docker setup, it fixes the issue.
Thank you for your fingerpointing.

ggrossetie pushed a commit that referenced this issue Aug 6, 2023
* Fix #1602

Copy the same workaround as in mermaid https://github.com/yuzutech/kroki/blob/main/mermaid/src/index.js#L28-L29

* Add a testcase for diagramsnet which have a query parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants