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

Some SVG & PNG source icons fail to appear in diagram but d2 command returns successful exit code 0 #2367

Closed
HariSekhon opened this issue Feb 20, 2025 · 1 comment · Fixed by #2370

Comments

@HariSekhon
Copy link

HariSekhon commented Feb 20, 2025

Summary

Some icon imports are not working - d2 generates broken diagrams with missing icons but exits with success code 0.

Example Code to Reproduce

I use classes for icon reuse - these work:

classes: {
  docker: {
    label: Docker
    icon: https://icons.terrastruct.com/dev%2Fdocker.svg
    shape: image
  }
  cloudbuild: {
    label: Cloud Build
    icon: https://icons.terrastruct.com/gcp%2FProducts%20and%20services%2FDeveloper%20Tools%2FCloud%20Build.svg
    shape: image
  }
}

docker.class: docker
cloudbuild.class: cloudbuild

but these don't:

classes: {
  clair: {
    label: Clair
    icon: https://worldvectorlogo.com/download/clair.svg
    shape: image
  }
  sonarqube: {
    label: SonarQube
    icon:  https://worldvectorlogo.com/download/sonarqube.svg
    #icon: https://icons-for-free.com/iff/png/256/sonarqube-1336519700268537013.png  # same thing happens with this png
    shape: image
  }
}

clair.class: clair
sonarqube.class: sonarqube

but if I wget and open the icons they look correct.

Proposed Solution

D2 should verify the icons format and error out if failing to pull icons correctly, or if they're invalid due to websites sending back some 403 style textual error, rather than generating diagrams with broken icon placeholders in them and returning exit code 0.

The full source code template showing this usage can be seen here:

https://github.com/HariSekhon/Templates/blob/master/diagram.d2

or throughout my real world HariSekhon/Diagrams-as-Code repo.

These failures to import these icons result in no error but missing icons in the diagram and still the d2 command returns a successful exit code 0.

This is bad because my HariSekhon/Diagrams-as-Code repo uses GitHub Actions to automatically (re)generate d2 diagrams upon any change to their source code and if it can't detect these sorts of breakages then it will update the diagram with broken icons and save that, which it has, and had to be noticed by me manually due to d2 not doing correct exit code signalling.

@cyborg-ts cyborg-ts added this to D2 Feb 20, 2025
@HariSekhon HariSekhon changed the title Some SVG source icons fail to appear in diagram but d2 command returns successful exit code 0 Some SVG & PNG source icons fail to appear in diagram but d2 command returns successful exit code 0 Feb 20, 2025
@alixander
Copy link
Collaborator

alixander commented Feb 21, 2025

This was another bug (d2 cli should complain on invalid remote images, it was giving 200 but the cli wasn't interpreting the response correctly), thank you for filing it, will be fixed in next release: #2370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants