theforeman / foreman_puppet

https://theforeman.org/plugins/foreman_puppet/
GNU General Public License v3.0
7 stars 24 forks source link

Search autocomplete on puppetclass throws errors #365

Open nadjaheitmann opened 1 year ago

nadjaheitmann commented 1 year ago

In UI, you can see Error: Request failed with status code 500

In the logs, you can see (not sure what is relevant here) 09:16:11 rails.1 | 2023-08-01T09:16:11 [I|app|fe9dade4] Started GET "/hosts/auto_complete_search?search=puppetclass++%3D" for 192.168.121.1 at 2023-08-01 09:16:11 +0000 09:16:11 rails.1 | 2023-08-01T09:16:11 [I|app|fe9dade4] Processing by HostsController#auto_complete_search as JSON 09:16:11 rails.1 | 2023-08-01T09:16:11 [I|app|fe9dade4] Parameters: {"search"=>"puppetclass ="} 09:16:11 rails.1 | 2023-08-01T09:16:11 [I|app|fe9dade4] Completed 500 Internal Server Error in 17ms (ActiveRecord: 3.9ms | Allocations: 9776) 09:16:11 rails.1 | fe9dade4 | 09:16:11 rails.1 | fe9dade4 | 09:16:11 rails.1 | 2023-08-01T09:16:11 [F|app|fe9dade4]
09:16:11 rails.1 | fe9dade4 | NoMethodError (undefined method 'klass' for nil:NilClass): 09:16:11 rails.1 | fe9dade4 |
09:16:11 rails.1 | fe9dade4 | app/models/host/managed.rb:40:in 'complete_for' 09:16:11 rails.1 | fe9dade4 | app/controllers/concerns/foreman/controller/auto_complete_search.rb:12:in 'auto_complete_search' 09:16:11 rails.1 | fe9dade4 | app/controllers/concerns/foreman/controller/timezone.rb:10:in 'set_timezone' 09:16:11 rails.1 | fe9dade4 | app/models/concerns/foreman/thread_session.rb:32:in 'clear_thread' 09:16:11 rails.1 | fe9dade4 | app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in 'set_topbar_sweeper_controller' 09:16:11 rails.1 | fe9dade4 | /home/vagrant/katello/lib/katello/middleware/organization_created_enforcer.rb:18:in 'call' 09:16:11 rails.1 | fe9dade4 | /home/vagrant/katello/lib/katello/middleware/event_daemon.rb:10:in 'call' 09:16:11 rails.1 | fe9dade4 | lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in 'call' 09:16:11 rails.1 | fe9dade4 | lib/foreman/middleware/telemetry.rb:10:in 'call' 09:16:11 rails.1 | fe9dade4 | lib/foreman/middleware/logging_context_session.rb:22:in 'call' 09:16:11 rails.1 | fe9dade4 | lib/foreman/middleware/logging_context_request.rb:11:in 'call' 09:16:11 rails.1 | fe9dade4 | /home/vagrant/katello/lib/katello/prevent_json_parsing.rb:12:in 'call' 09:16:12 rails.1 | 2023-08-01T09:16:12 [I|app|fe9dade4] Rendered .vendor/ruby/2.7.0/gems/actionpack-6.1.7.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb (Duration: 7.9ms | Allocations: 1804)

Foreman-rake console (this one is actually fixed but it sepicts where it was failing all along): pry(main)> Hostgroup.search_for('class = motd') NoMethodError: undefined method 'klass' for nil:NilClass from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/scoped_search-4.1.11/lib/scoped_search/definition.rb:99:in 'klass'

nadjaheitmann commented 1 year ago

The autocomplete also fails for host/hostgroup search for the config_group keyword

nadjaheitmann commented 1 year ago

@stejskalleos Are you going to look into this?