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

When there's a syntax error and the Accept request HTTP header is "image/*" we should return an image #842

Closed
ggrossetie opened this issue Aug 2, 2021 · 1 comment · Fixed by #857
Labels
💡 proposal 🍩 enhancement New feature or request ☕ java Related to Java code

Comments

@ggrossetie
Copy link
Member

Currently, Kroki will return the error message as plain text.
As a result, we get a broken image icon when using an <img> element:

<html>
<body>
<img src="https://kroki.io/plantuml/svg/eNpLstFVTAQABAkBTg=="/>
</body>
</html>

Chrome
image

Firefox
image

Instead, it would be useful to show the error message as an image:

image

@ggrossetie ggrossetie added 🍩 enhancement New feature or request ☕ java Related to Java code 💡 proposal labels Aug 2, 2021
@ggrossetie
Copy link
Member Author

I wonder if it should be optional. Arguably, this is only really useful when editing diagrams and we probably don't want to show an error on a live site...? 🤔

So maybe it should be disabled by default and enabled using a query parameter, such as ?show-error?

Otherwise, we could decide that this is not our responsibility. Users could use the following approach to hide the image when something is wrong:

<img src="https://kroki.io/plantuml/svg/eNpLstFVTAQABAkBTg==" onerror="this.style.display='none'"/>

Or even display a placeholder image:

<img src="https://kroki.io/plantuml/svg/eNpLstFVTAQABAkBTg==" onerror="this.src='fallback-img.jpg'"/>

ggrossetie added a commit to ggrossetie/kroki that referenced this issue Aug 9, 2021
Use svgSalamander to create SVG and PNG images.
Batik adds ~7mb of dependencies.
ggrossetie added a commit to ggrossetie/kroki that referenced this issue Aug 9, 2021
Use svgSalamander to create SVG and PNG images.
Batik adds ~7mb of dependencies.
ggrossetie added a commit to ggrossetie/kroki that referenced this issue Aug 9, 2021
Use svgSalamander to create SVG and PNG images.
Batik adds ~7mb of dependencies.
ggrossetie added a commit to ggrossetie/kroki that referenced this issue Aug 9, 2021
Use svgSalamander to create SVG and PNG images.
Batik adds ~7mb of dependencies.
ggrossetie added a commit to ggrossetie/kroki that referenced this issue Aug 9, 2021
Use svgSalamander to create SVG and PNG images.
Batik adds ~7mb of dependencies.
ggrossetie added a commit to ggrossetie/kroki that referenced this issue Oct 17, 2021
Otherwise, Kroki does not return an error image when the Accept header contains more than one MIME-type.
Reference yuzutech#842
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 proposal 🍩 enhancement New feature or request ☕ java Related to Java code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant