[arvados] created: 2.1.0-2788-g6cd62b6e2
git repository hosting
git at public.arvados.org
Wed Jul 27 19:14:51 UTC 2022
at 6cd62b6e286d4470ef9e2b2c70653d78a05f8cf2 (commit)
commit 6cd62b6e286d4470ef9e2b2c70653d78a05f8cf2
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Wed Jul 27 16:07:56 2022 -0300
19297: Raises an error only when no object types have the requested attribute.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/services/api/app/controllers/arvados/v1/groups_controller.rb b/services/api/app/controllers/arvados/v1/groups_controller.rb
index 3473c7e4e..de0c43a77 100644
--- a/services/api/app/controllers/arvados/v1/groups_controller.rb
+++ b/services/api/app/controllers/arvados/v1/groups_controller.rb
@@ -263,6 +263,9 @@ class Arvados::V1::GroupsController < ApplicationController
included_by_uuid = {}
seen_last_class = false
+ error_by_class = {}
+ any_success = false
+
klasses.each do |klass|
# check if current klass is same as params['last_object_class']
seen_last_class = true if((params['count'].andand.==('none')) and
@@ -318,7 +321,19 @@ class Arvados::V1::GroupsController < ApplicationController
# Adjust the limit based on number of objects fetched so far
klass_limit = limit_all - all_objects.count
@limit = klass_limit
- apply_where_limit_order_params klass
+
+ begin
+ apply_where_limit_order_params klass
+ rescue ArgumentError => e
+ if e.inspect =~ /Invalid attribute '.+' for operator '.+' in filter/ or
+ e.inspect =~ /Invalid attribute '.+' for subproperty filter/
+ error_by_class[klass.name] = e
+ next
+ end
+ raise
+ else
+ any_success = true
+ end
# This actually fetches the objects
klass_object_list = object_list(model_class: klass)
@@ -349,6 +364,14 @@ class Arvados::V1::GroupsController < ApplicationController
end
end
+ # Only error out when every searchable object type errored out
+ if !any_success
+ error_msg = error_by_class.collect do |klass, err|
+ "#{err} on object type #{klass}"
+ end.join("\n")
+ raise ArgumentError.new(error_msg)
+ end
+
if params["include"]
@extra_included = included_by_uuid.values
end
diff --git a/services/api/lib/record_filters.rb b/services/api/lib/record_filters.rb
index 2f5b67074..65c25810a 100644
--- a/services/api/lib/record_filters.rb
+++ b/services/api/lib/record_filters.rb
@@ -136,7 +136,7 @@ module RecordFilters
raise ArgumentError.new("Invalid operator for subproperty search '#{operator}'")
end
elsif operator == "exists"
- if col.type != :jsonb
+ if col.nil? or col.type != :jsonb
raise ArgumentError.new("Invalid attribute '#{attr}' for operator '#{operator}' in filter")
end
commit a46fce5c3bfdf6b5a7fcc817309970156bcdc5b8
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Wed Jul 27 16:07:17 2022 -0300
19297: Adds tests exposing the bug.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/services/api/test/functional/arvados/v1/filters_test.rb b/services/api/test/functional/arvados/v1/filters_test.rb
index dd8eeaa7b..7eac47771 100644
--- a/services/api/test/functional/arvados/v1/filters_test.rb
+++ b/services/api/test/functional/arvados/v1/filters_test.rb
@@ -236,6 +236,48 @@ class Arvados::V1::FiltersTest < ActionController::TestCase
json_response['errors'].join(' '))
end
+ test "groups contents with properties filter succeeds on objects with properties field" do
+ @controller = Arvados::V1::GroupsController.new
+ authorize_with :admin
+ get :contents, params: {
+ filters: [
+ ['properties', 'exists', 'foo'],
+ ['uuid', 'is_a', ["arvados#group","arvados#collection","arvados#containerRequest"]],
+ ]
+ }
+ assert_response 200
+ assert json_response['items'].length == 0
+ end
+
+ # Tests bug #19297
+ test "groups contents with properties filter succeeds on some objects with properties field" do
+ @controller = Arvados::V1::GroupsController.new
+ authorize_with :admin
+ get :contents, params: {
+ filters: [
+ ['properties', 'exists', 'foo'],
+ ['uuid', 'is_a', ["arvados#group","arvados#workflow"]],
+ ]
+ }
+ assert_response 200
+ assert json_response['items'].length == 0
+ end
+
+ # Tests bug #19297
+ test "groups contents with properties filter fails on objects without properties field" do
+ @controller = Arvados::V1::GroupsController.new
+ authorize_with :admin
+ get :contents, params: {
+ 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 "replication_desired = 2" do
@controller = Arvados::V1::CollectionsController.new
authorize_with :admin
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list