[ARVADOS] created: 1.3.0-1895-g92d7d779d
Git user
git at public.curoverse.com
Thu Nov 21 15:51:51 UTC 2019
at 92d7d779d4f0415d09f536d286972bd953e7b566 (commit)
commit 92d7d779d4f0415d09f536d286972bd953e7b566
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date: Thu Nov 21 10:49:56 2019 -0500
15851: Return items [], not null, in empty set responses.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>
diff --git a/lib/controller/federation/generated.go b/lib/controller/federation/generated.go
index b34b9b165..2e6eda7ff 100755
--- a/lib/controller/federation/generated.go
+++ b/lib/controller/federation/generated.go
@@ -38,6 +38,12 @@ func (conn *Conn) ContainerList(ctx context.Context, options arvados.ListOptions
return uuids, nil
})
sort.Slice(merged.Items, func(i, j int) bool { return merged.Items[i].UUID < merged.Items[j].UUID })
+ if merged.Items == nil {
+ // Return empty results as [], not null
+ // (https://github.com/golang/go/issues/27589 might be
+ // a better solution in the future)
+ merged.Items = []arvados.Container{}
+ }
return merged, err
}
@@ -63,5 +69,11 @@ func (conn *Conn) SpecimenList(ctx context.Context, options arvados.ListOptions)
return uuids, nil
})
sort.Slice(merged.Items, func(i, j int) bool { return merged.Items[i].UUID < merged.Items[j].UUID })
+ if merged.Items == nil {
+ // Return empty results as [], not null
+ // (https://github.com/golang/go/issues/27589 might be
+ // a better solution in the future)
+ merged.Items = []arvados.Specimen{}
+ }
return merged, err
}
diff --git a/lib/controller/federation/list.go b/lib/controller/federation/list.go
index 6ba184c47..0c6bef497 100644
--- a/lib/controller/federation/list.go
+++ b/lib/controller/federation/list.go
@@ -42,6 +42,12 @@ func (conn *Conn) CollectionList(ctx context.Context, options arvados.ListOption
return uuids, nil
})
sort.Slice(merged.Items, func(i, j int) bool { return merged.Items[i].UUID < merged.Items[j].UUID })
+ if merged.Items == nil {
+ // Return empty results as [], not null
+ // (https://github.com/golang/go/issues/27589 might be
+ // a better solution in the future)
+ merged.Items = []arvados.Collection{}
+ }
return merged, err
}
diff --git a/lib/controller/federation/list_test.go b/lib/controller/federation/list_test.go
index c9b981fc1..27d6da98c 100644
--- a/lib/controller/federation/list_test.go
+++ b/lib/controller/federation/list_test.go
@@ -426,7 +426,7 @@ func (s *CollectionListSuite) test(c *check.C, trial listTrial) {
c.Logf("returned error string is %q", err)
} else {
c.Check(err, check.IsNil)
- var expectItems []arvados.Collection
+ expectItems := []arvados.Collection{}
for _, uuid := range trial.expectUUIDs {
expectItems = append(expectItems, arvados.Collection{UUID: uuid})
}
diff --git a/lib/controller/router/router_test.go b/lib/controller/router/router_test.go
index 3a7045aa4..a42df278f 100644
--- a/lib/controller/router/router_test.go
+++ b/lib/controller/router/router_test.go
@@ -225,6 +225,13 @@ func (s *RouterIntegrationSuite) TestContainerList(c *check.C) {
c.Check(rr.Code, check.Equals, http.StatusOK)
c.Check(jresp["items_available"], check.FitsTypeOf, float64(0))
c.Check(jresp["items_available"].(float64) > 2, check.Equals, true)
+ c.Check(jresp["items"], check.NotNil)
+ c.Check(jresp["items"], check.HasLen, 0)
+
+ _, rr, jresp = doRequest(c, s.rtr, token, "GET", `/arvados/v1/containers?filters=[["uuid","in",[]]]`, nil, nil)
+ c.Check(rr.Code, check.Equals, http.StatusOK)
+ c.Check(jresp["items_available"], check.Equals, float64(0))
+ c.Check(jresp["items"], check.NotNil)
c.Check(jresp["items"], check.HasLen, 0)
_, rr, jresp = doRequest(c, s.rtr, token, "GET", `/arvados/v1/containers?limit=2&select=["uuid","command"]`, nil, nil)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list