Bug #12959
closedHost search based on fact value using LIKE clause does'nt work
Description
Hi,
If I search hosts using a fact value and a ~ it doesn't work as in 1.9.3.
For exemple, if I want to find the hosts having the fact my_fact containing the string fact1 (but can be fact1,fact2,fact3,...), the expression "facts.my_fact ~ fact1" will give me only the hosts for which my_fact is exactly fact1
If I try to use _ or * wildcards it does'nt change anything.
If I use fact1 I've got an error : "too few arguments".
If I call the url "/hosts?format=yaml&rundeck=true&search=+facts.my_fact+~+%25fact1%25" I see an error in the logs :
2015-12-30T17:30:47 [app] [I] Started GET "/hosts?format=yaml&rundeck=true&search=+facts.my_fact+~+%25fact1%25" for 172.16.1.250 at 2015-12-30 17:30:47 +0100 2015-12-30T17:30:47 [app] [I] Processing by HostsController#index as YAML 2015-12-30T17:30:47 [app] [I] Parameters: {"rundeck"=>"true", "search"=>" facts.my_fact ~ %fact1%"} 2015-12-30T17:30:47 [app] [W] Action failed | ArgumentError: too few arguments | /usr/share/foreman/vendor/ruby/2.1.0/gems/fast_gettext-0.9.2/lib/fast_gettext/vendor/string.rb:70:in `%' | /usr/share/foreman/vendor/ruby/2.1.0/gems/fast_gettext-0.9.2/lib/fast_gettext/vendor/string.rb:70:in `%' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/sanitization.rb:121:in `sanitize_sql_array' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/sanitization.rb:28:in `sanitize_sql_for_conditions' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/query_methods.rb:324:in `build_where' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/query_methods.rb:136:in `where' | /usr/share/foreman/vendor/ruby/2.1.0/gems/scoped_search-3.2.2/lib/scoped_search/definition.rb:256:in `block in register_named_scope!' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/scoping/named.rb:178:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/scoping/named.rb:178:in `block (2 levels) in scope' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/scoping/default.rb:41:in `block in unscoped' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation.rb:241:in `block in scoping' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/scoping.rb:98:in `with_scope' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation.rb:241:in `scoping' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/scoping/default.rb:41:in `unscoped' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/scoping/named.rb:178:in `block in scope' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/delegation.rb:14:in `block in search_for' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation.rb:241:in `block in scoping' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/scoping.rb:98:in `with_scope' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation.rb:241:in `scoping' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/delegation.rb:14:in `search_for' | /usr/share/foreman/vendor/ruby/2.1.0/gems/foreman_host_rundeck-0.0.2/app/controllers/concerns/foreman_host_rundeck/hosts_controller_extensions.rb:13:in `index_with_rundeck' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_controller/metal/implicit_render.rb:4:in `send_action' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/abstract_controller/base.rb:167:in `process_action' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_controller/metal/rendering.rb:10:in `process_action' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/abstract_controller/callbacks.rb:18:in `block in process_action' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:649:in `block (4 levels) in _run__2499070075575149213__process_action__4570805294882249613__callbacks' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_8158' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:326:in `around' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:310:in `_callback_around_2510' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_8158' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:637:in `block (3 levels) in _run__2499070075575149213__process_action__4570805294882249613__callbacks' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_8157' | /usr/share/foreman/app/controllers/concerns/application_shared.rb:13:in `set_timezone' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_8157' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:636:in `block (2 levels) in _run__2499070075575149213__process_action__4570805294882249613__callbacks' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_8156' | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_8156' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:448:in `block in _run__2499070075575149213__process_action__4570805294882249613__callbacks' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_8155' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:326:in `around' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:310:in `_callback_around_13' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_8155' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:414:in `_run__2499070075575149213__process_action__4570805294882249613__callbacks' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:405:in `__run_callback' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:81:in `run_callbacks' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/abstract_controller/callbacks.rb:17:in `process_action' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_controller/metal/rescue.rb:29:in `process_action' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/notifications.rb:123:in `block in instrument' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/notifications/instrumenter.rb:20:in `instrument' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/notifications.rb:123:in `instrument' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_controller/metal/instrumentation.rb:29:in `process_action' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_controller/metal/params_wrapper.rb:207:in `process_action' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/railties/controller_runtime.rb:18:in `process_action' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/abstract_controller/base.rb:121:in `process' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/abstract_controller/rendering.rb:45:in `process' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_controller/metal.rb:203:in `dispatch' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_controller/metal.rb:246:in `block in action' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/routing/route_set.rb:73:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/routing/route_set.rb:73:in `dispatch' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/routing/route_set.rb:36:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/journey-1.0.4/lib/journey/router.rb:56:in `each' | /usr/share/foreman/vendor/ruby/2.1.0/gems/journey-1.0.4/lib/journey/router.rb:56:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/routing/route_set.rb:608:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/apipie-rails-0.2.6/lib/apipie/static_dispatcher.rb:65:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/apipie-rails-0.2.6/lib/apipie/extractor/recorder.rb:97:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/apipie-rails-0.2.6/lib/apipie/middleware/checksum_in_headers.rb:27:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.4.7/lib/rack/etag.rb:23:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.4.7/lib/rack/conditionalget.rb:25:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/head.rb:14:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/params_parser.rb:21:in `call' | /usr/share/foreman/lib/middleware/catch_json_parse_errors.rb:9:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/flash.rb:242:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.4.7/lib/rack/session/abstract/id.rb:210:in `context' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.4.7/lib/rack/session/abstract/id.rb:205:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/cookies.rb:341:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/query_cache.rb:64:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:405:in `_run__640040847829197367__call__791296085174225863__callbacks' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:405:in `__run_callback' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:385:in `_run_call_callbacks' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:81:in `run_callbacks' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/callbacks.rb:27:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/remote_ip.rb:31:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/railties-3.2.21/lib/rails/rack/logger.rb:32:in `call_app' | /usr/share/foreman/vendor/ruby/2.1.0/gems/railties-3.2.21/lib/rails/rack/logger.rb:18:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/request_id.rb:22:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.4.7/lib/rack/methodoverride.rb:21:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.4.7/lib/rack/runtime.rb:17:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-3.2.21/lib/active_support/cache/strategy/local_cache.rb:72:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.4.7/lib/rack/lock.rb:15:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/static.rb:83:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/railties-3.2.21/lib/rails/engine.rb:484:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/railties-3.2.21/lib/rails/application.rb:231:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/railties-3.2.21/lib/rails/railtie/configurable.rb:30:in `method_missing' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.4.7/lib/rack/builder.rb:134:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.4.7/lib/rack/urlmap.rb:64:in `block in call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.4.7/lib/rack/urlmap.rb:49:in `each' | /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.4.7/lib/rack/urlmap.rb:49:in `call' | /usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request' | /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request' | /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop' | /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:455:in `block (3 levels) in start_threads' | /usr/share/foreman/vendor/ruby/2.1.0/gems/logging-2.0.0/lib/logging/diagnostic_context.rb:448:in `call' | /usr/share/foreman/vendor/ruby/2.1.0/gems/logging-2.0.0/lib/logging/diagnostic_context.rb:448:in `block in create_with_logging_context' 2015-12-30T17:30:47 [app] [I] Completed 500 Internal Server Error in 9.3ms
That's a big problem for us as we use this feature to add hosts to our rundeck projects. As it doesn't work, rundeck projects don't have any nodes now.
Updated by Dominic Cleal almost 9 years ago
- Category set to Search
Can you confirm which release(s) you're using? Are you saying it worked in 1.9.3 and now you're using 1.10.0 and it isn't?
Updated by Brice Sauvajon almost 9 years ago
Yes, that's it, it worked on 1.9.3 and it's broken since the upgrade to 1.10.0
Updated by Dominic Cleal almost 9 years ago
- Related to Feature #11150: Allow searching of facts as types other than string added
Updated by Dominic Cleal almost 9 years ago
- Translation missing: en.field_release set to 104
Updated by Dominic Cleal almost 9 years ago
- Status changed from New to Assigned
- Assignee set to Dominic Cleal
Updated by The Foreman Bot almost 9 years ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/3026 added
Updated by Dominic Cleal almost 9 years ago
- Related to Bug #13035: Host fact search using ~ operator doesn't automatically add wildcards added
Updated by Dominic Cleal almost 9 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 1e12a718c17d9c2b0c65455e96102e7b4c2925a6.