Skip to content

Commit eca164d

Browse files
committed
cloudapi: Fix listing composes with empty result
It was returning a null body instead of an empty list. Related: RHEL-60120
1 parent 7e820ad commit eca164d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

internal/cloudapi/v2/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func (h *apiHandlers) GetComposeList(ctx echo.Context) error {
313313
}
314314

315315
// Gather up the details of each job
316-
var stats []ComposeStatus
316+
stats := []ComposeStatus{}
317317
for _, jid := range jobs {
318318
s, err := h.getJobIDComposeStatus(jid)
319319
if err != nil {

internal/cloudapi/v2/v2_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,10 @@ func TestComposesRoute(t *testing.T) {
18871887
srv, _, _, cancel := newV2Server(t, t.TempDir(), false, false)
18881888
defer cancel()
18891889

1890+
// List empty root composes
1891+
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", "/api/image-builder-composer/v2/composes/", ``,
1892+
http.StatusOK, `[]`)
1893+
18901894
// Make a compose so it has something to list
18911895
reply := test.TestRouteWithReply(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
18921896
{

0 commit comments

Comments
 (0)