diff --git a/internal/cloudapi/v2/handler.go b/internal/cloudapi/v2/handler.go index 863f2e35c..2144800ba 100644 --- a/internal/cloudapi/v2/handler.go +++ b/internal/cloudapi/v2/handler.go @@ -313,7 +313,7 @@ func (h *apiHandlers) GetComposeList(ctx echo.Context) error { } // Gather up the details of each job - var stats []ComposeStatus + stats := []ComposeStatus{} for _, jid := range jobs { s, err := h.getJobIDComposeStatus(jid) if err != nil { diff --git a/internal/cloudapi/v2/v2_test.go b/internal/cloudapi/v2/v2_test.go index f272f95b6..dc970b9b3 100644 --- a/internal/cloudapi/v2/v2_test.go +++ b/internal/cloudapi/v2/v2_test.go @@ -1887,6 +1887,10 @@ func TestComposesRoute(t *testing.T) { srv, _, _, cancel := newV2Server(t, t.TempDir(), false, false) defer cancel() + // List empty root composes + test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", "/api/image-builder-composer/v2/composes/", ``, + http.StatusOK, `[]`) + // Make a compose so it has something to list reply := test.TestRouteWithReply(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(` {