Skip to content

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

@HariSekhon

Description

@HariSekhon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions