19297: Fixes error check for edge case of limit=0, count=none. Adds test. 19297-inexistent-field-filter-fix
authorLucas Di Pentima <lucas.dipentima@curii.com>
Thu, 28 Jul 2022 14:11:47 +0000 (11:11 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Thu, 28 Jul 2022 14:11:47 +0000 (11:11 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

services/api/app/controllers/arvados/v1/groups_controller.rb
services/api/test/functional/arvados/v1/filters_test.rb

index de0c43a77e5880bdffa0e8f5167a5d616383f3fd..e9bc006a36664bb1a929bf72dccc9730fa9b049c 100644 (file)
@@ -365,7 +365,7 @@ class Arvados::V1::GroupsController < ApplicationController
     end
 
     # Only error out when every searchable object type errored out
-    if !any_success
+    if !any_success && error_by_class.size > 0
       error_msg = error_by_class.collect do |klass, err|
         "#{err} on object type #{klass}"
       end.join("\n")
index 7eac477716ecc0f010be567f588c4f90fa24c742..3916d63c5ed1cce10cca11182b23682db512d8d1 100644 (file)
@@ -271,13 +271,23 @@ class Arvados::V1::FiltersTest < ActionController::TestCase
       filters: [
         ['properties', 'exists', 'foo'],
         ['uuid', 'is_a', ["arvados#workflow"]],
-      ],
-      limit: 1
+      ]
     }
     assert_response 422
     assert_match(/Invalid attribute 'properties' for operator 'exists'.*on object type Workflow/, json_response['errors'].join(' '))
   end
 
+  test "groups contents without filters and limit=0, count=none" do
+    @controller = Arvados::V1::GroupsController.new
+    authorize_with :admin
+    get :contents, params: {
+      limit: 0,
+      count: 'none',
+    }
+    assert_response 200
+    assert json_response['items'].length == 0
+  end
+
   test "replication_desired = 2" do
     @controller = Arvados::V1::CollectionsController.new
     authorize_with :admin