Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: panic on image detail view
Kyle Mendellb45591945527
diff --git a/backend/internal/services/image_service.go b/backend/internal/services/image_service.goindex 6b281db45..250d2ab73 100644--- a/backend/internal/services/image_service.go+++ b/backend/internal/services/image_service.go@@ -89,7 +89,7 @@ func (s *ImageService) GetImageDetail(ctx context.Context, id string) (*imagetypreturn nil, err}- out := imagetypes.NewDetailSummary(new(inspect))+ out := imagetypes.NewDetailSummary(&inspect)if listSize > 0 {out.Size = listSizeout.Descriptor.Size = listSizediff --git a/types/image/image.go b/types/image/image.goindex 2861b4601..45f30ed56 100644--- a/types/image/image.go+++ b/types/image/image.go@@ -516,6 +516,9 @@ func (p PullOptions) GetCredentials() []containerregistry.Credential {// to string keys. The descriptor is derived from the first repo digest if available.func NewDetailSummary(src *image.InspectResponse) DetailSummary {var out DetailSummary+ if src == nil {+ return out+ }out.ID = src.IDout.RepoTags = append(out.RepoTags, src.RepoTags...)@@ -551,9 +554,11 @@ func NewDetailSummary(src *image.InspectResponse) DetailSummary {out.Os = src.Osout.Size = src.Size- out.GraphDriver.Name = src.GraphDriver.Name- if src.GraphDriver.Data != nil {- out.GraphDriver.Data = src.GraphDriver.Data+ if src.GraphDriver != nil {+ out.GraphDriver.Name = src.GraphDriver.Name+ if src.GraphDriver.Data != nil {+ out.GraphDriver.Data = src.GraphDriver.Data+ }}out.RootFs.Type = src.RootFS.Typediff --git a/types/image/image_test.go b/types/image/image_test.gonew file mode 100644index 000000000..5e769303b--- /dev/null+++ b/types/image/image_test.go@@ -0,0 +1,54 @@+package image++import (+ "reflect"+ "testing"++ dockerimage "github.com/moby/moby/api/types/image"+)++func TestNewDetailSummary_NilSource(t *testing.T) {+ got := NewDetailSummary(nil)+ want := DetailSummary{}++ if !reflect.DeepEqual(got, want) {+ t.Fatalf("expected zero-value DetailSummary for nil source, got %#v", got)+ }+}++func TestNewDetailSummary_HandlesNilGraphDriver(t *testing.T) {+ src := &dockerimage.InspectResponse{+ ID: "sha256:test-id",+ RepoTags: []string{"alpine:3.20"},+ RepoDigests: []string{"docker.io/library/alpine@sha256:deadbeef"},+ Comment: "test-comment",+ Created: "2026-03-05T03:58:10.000000000Z",+ Author: "arcane-test",+ Architecture: "amd64",+ Os: "linux",+ Size: 42,+ RootFS: dockerimage.RootFS{+ Type: "layers",+ Layers: []string{"sha256:l1", "sha256:l2"},+ },+ GraphDriver: nil,+ }++ got := NewDetailSummary(src)++ if got.ID != src.ID {+ t.Fatalf("expected ID %q, got %q", src.ID, got.ID)+ }+ if got.GraphDriver.Name != "" {+ t.Fatalf("expected empty graph driver name when source GraphDriver is nil, got %q", got.GraphDriver.Name)+ }+ if got.Descriptor.Digest != "sha256:deadbeef" {+ t.Fatalf("expected descriptor digest to be parsed from repo digest, got %q", got.Descriptor.Digest)+ }+ if got.RootFs.Type != "layers" {+ t.Fatalf("expected RootFs.Type to be %q, got %q", "layers", got.RootFs.Type)+ }+ if len(got.RootFs.Layers) != 2 {+ t.Fatalf("expected 2 rootfs layers, got %d", len(got.RootFs.Layers))+ }+}