[ARVADOS] created: 2.1.0-756-g471f26a8c

Git user git at public.arvados.org
Tue May 4 20:02:03 UTC 2021


        at  471f26a8c42eda91184cb88211163840aacd5e8c (commit)


commit 471f26a8c42eda91184cb88211163840aacd5e8c
Author: Tom Clegg <tom at curii.com>
Date:   Tue May 4 14:20:27 2021 -0400

    17587: Don't reject federated query with large limit param.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/lib/controller/federation/list.go b/lib/controller/federation/list.go
index bc6d3e00a..183557eb1 100644
--- a/lib/controller/federation/list.go
+++ b/lib/controller/federation/list.go
@@ -205,8 +205,8 @@ func (conn *Conn) splitListRequest(ctx context.Context, opts arvados.ListOptions
 	if opts.Count != "none" {
 		return httpErrorf(http.StatusBadRequest, "cannot execute federated list query unless count==\"none\"")
 	}
-	if opts.Limit >= 0 || opts.Offset != 0 || len(opts.Order) > 0 {
-		return httpErrorf(http.StatusBadRequest, "cannot execute federated list query with limit, offset, or order parameter")
+	if (opts.Limit >= 0 && opts.Limit < int64(nUUIDs)) || opts.Offset != 0 || len(opts.Order) > 0 {
+		return httpErrorf(http.StatusBadRequest, "cannot execute federated list query with limit (%d) < nUUIDs (%d), offset (%d) > 0, or order (%v) parameter", opts.Limit, nUUIDs, opts.Offset, opts.Order)
 	}
 	if max := conn.cluster.API.MaxItemsPerResponse; nUUIDs > max {
 		return httpErrorf(http.StatusBadRequest, "cannot execute federated list query because number of UUIDs (%d) exceeds page size limit %d", nUUIDs, max)
diff --git a/lib/controller/federation/list_test.go b/lib/controller/federation/list_test.go
index e6d2816f6..2a4e230c9 100644
--- a/lib/controller/federation/list_test.go
+++ b/lib/controller/federation/list_test.go
@@ -300,6 +300,7 @@ func (s *CollectionListSuite) TestCollectionListMultiSiteExtraFilters(c *check.C
 
 func (s *CollectionListSuite) TestCollectionListMultiSiteWithCount(c *check.C) {
 	for _, count := range []string{"", "exact"} {
+		s.SetUpTest(c)
 		s.test(c, listTrial{
 			count: count,
 			limit: -1,
@@ -315,11 +316,12 @@ func (s *CollectionListSuite) TestCollectionListMultiSiteWithCount(c *check.C) {
 
 func (s *CollectionListSuite) TestCollectionListMultiSiteWithLimit(c *check.C) {
 	for _, limit := range []int64{0, 1, 2} {
+		s.SetUpTest(c)
 		s.test(c, listTrial{
 			count: "none",
 			limit: limit,
 			filters: []arvados.Filter{
-				{"uuid", "in", []string{s.uuids[0][0], s.uuids[1][0]}},
+				{"uuid", "in", []string{s.uuids[0][0], s.uuids[1][0], s.uuids[2][0]}},
 				{"uuid", "is_a", "teapot"},
 			},
 			expectCalls:  []int{0, 0, 0},
@@ -328,6 +330,22 @@ func (s *CollectionListSuite) TestCollectionListMultiSiteWithLimit(c *check.C) {
 	}
 }
 
+func (s *CollectionListSuite) TestCollectionListMultiSiteWithHighLimit(c *check.C) {
+	uuids := []string{s.uuids[0][0], s.uuids[1][0], s.uuids[2][0]}
+	for _, limit := range []int64{3, 4, 1234567890} {
+		s.SetUpTest(c)
+		s.test(c, listTrial{
+			count: "none",
+			limit: limit,
+			filters: []arvados.Filter{
+				{"uuid", "in", uuids},
+			},
+			expectUUIDs: uuids,
+			expectCalls: []int{1, 1, 1},
+		})
+	}
+}
+
 func (s *CollectionListSuite) TestCollectionListMultiSiteWithOffset(c *check.C) {
 	s.test(c, listTrial{
 		count:  "none",

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list