Bug #31523
closedSearching for content view filter with just "inclusion_type" will return ISE
Description
This was seen because of the autocomplete search, to reproduce you can send something like:
curl -g -k -u admin:changeme -H "Content-Type: application/json" localhost:3000/katello/api/v2/content_view_filters?content_view_id=5&per_page=20&page=1&search=inclusion_type
Error:
2020-12-16T19:01:21 [I|app|94643dc4] Started GET "/katello/api/v2/content_view_filters?content_view_id=5&per_page=20&page=1&search=inclusion_type" for ::1 at 2020-12-16 19:01:21 +0000
2020-12-16T19:01:21 [I|app|94643dc4] Processing by Katello::Api::V2::ContentViewFiltersController#index as JSON
2020-12-16T19:01:21 [I|app|94643dc4] Parameters: {"content_view_id"=>"5", "per_page"=>"20", "page"=>"1", "search"=>"inclusion_type", "api_version"=>"v2"}
2020-12-16T19:01:21 [E|app|94643dc4] ActiveRecord::PreparedStatementInvalid: wrong number of bind variables (0 for 1) in: (["(\"katello_content_view_filters\".\"inclusion\" <> ?)", false])
94643dc4 | /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/sanitization.rb:209:in `raise_if_bind_arity_mismatch'
94643dc4 | /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/sanitization.rb:166:in `replace_bind_variables'
94643dc4 | /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/sanitization.rb:129:in `sanitize_sql_array'
94643dc4 | /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/sanitization.rb:26:in `sanitize_sql_for_conditions'
94643dc4 | /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/relation/where_clause_factory.rb:14:in `build'
94643dc4 | /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/relation/query_methods.rb:656:in `where!'
94643dc4 | /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/relation/query_methods.rb:649:in `where'
94643dc4 | /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/scoped_search-4.1.9/lib/scoped_search/definition.rb:329:in `block in register_named_scope!'
94643dc4 | /home/vagrant/katello/app/controllers/katello/api/v2/api_controller.rb:81:in `scoped_search'
94643dc4 | /home/vagrant/katello/app/controllers/katello/api/v2/content_view_filters_controller.rb:18:in `index'
94643dc4 | /home/vagrant/foreman/.vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'