Bug #19297


RailsAPI error when filtering by an inexistent column

Added by Lucas Di Pentima 7 months ago. Updated 6 months ago.

Assigned To:
Target version:
Start date:
Due date:
% Done:


Estimated time:
(Total: 0.00 h)
Story points:
Release relationship:


Workbench2 since v2.4.1 added arvados#workflow to the list of object types to include in its properties advanced search. The following is an example of filter passed to the controller:


This generate an error message like: 422 Unprocessable Entity: #<NoMethodError: undefined method `type' for nil:NilClass>

An example of backtrace from ce8i5:

"/var/www/arvados-api/current/lib/record_filters.rb:139:in `block (2 levels) in record_filters'
/var/www/arvados-api/current/lib/record_filters.rb:61:in `each'
/var/www/arvados-api/current/lib/record_filters.rb:61:in `block in record_filters'
/var/www/arvados-api/current/lib/record_filters.rb:32:in `each'
/var/www/arvados-api/current/lib/record_filters.rb:32:in `record_filters'
/var/www/arvados-api/current/app/models/arvados_model.rb:573:in `apply_filters'
/var/www/arvados-api/current/app/controllers/application_controller.rb:227:in `apply_filters'
/var/www/arvados-api/current/app/controllers/application_controller.rb:232:in `apply_where_limit_order_params'
/var/www/arvados-api/current/app/controllers/arvados/v1/groups_controller.rb:321:in `block in load_searchable_objects'
/var/www/arvados-api/current/app/controllers/arvados/v1/groups_controller.rb:266:in `each'

The workflows table doesn't currently have a properties column so it would seem that the code at record_filters.rb isn't handling this correctly.

Subtasks 1 (0 open1 closed)

Task #19304: Review 19297-inexistent-field-filter-fixResolvedLucas Di Pentima07/27/2022

Actions #1

Updated by Lucas Di Pentima 7 months ago

  • Status changed from New to In Progress
Actions #2

Updated by Lucas Di Pentima 7 months ago

Was able to produce the error by just making the groups#contents request with filters: [['properties', 'exists', 'foo']]

Actions #3

Updated by Lucas Di Pentima 7 months ago

Updates at 6cd62b6 - branch 19297-inexistent-field-filter-fix
Test run: developer-run-tests: #3249

  • Adds check for inexistent column on exists operator code path.
  • Record all the errors for every object type and re-raise them when every object type errored out.
  • Adds tests.

This update will make wb2 to not require any change because is making a search looking for properties on types that do have the properties field, in addition to workflows.

Actions #5

Updated by Tom Clegg 7 months ago

   # 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}" 

This fails with valid/no filters and limit=0 count=none, because we break out of the loop without setting the per-table params and therefore without setting any_success=true. Maybe worth changing to

   if !any_success && error_by_class.size > 0

This has the opposite problem that it would return OK with an invalid filter and limit=0 count=none. Since the results would always be empty, I'm not sure how much we should care about either case, but returning OK seems easier for client-side devs...?

Rest LGTM, thanks.

Actions #6

Updated by Lucas Di Pentima 7 months ago

Updates at 3e95703e7
Test run: developer-run-tests: #3250

  • Adds check so that it doesn't error out when limit=0, count=none is used, as suggested.
  • Adds test for this particular case.
Actions #7

Updated by Lucas Di Pentima 7 months ago

  • Status changed from In Progress to Resolved

Applied in changeset arvados-private:commit:arvados|1923ceda3c8845526f1ddcdd6275513760e0cd84.


Also available in: Atom PDF