Project

General

Profile

Actions

Bug #11255

closed

Cloning host with host group throws error: undefined method `[]' for nil:NilClass

Added by Dominic Cleal over 8 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Host creation
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Since #9591, when cloning a host with a host group associated, you get the following error:

 | ActionView::Template::Error (undefined method `[]' for nil:NilClass):
 |     60:         <div id="compute_profile" <%= display?(!@host.compute_resource_id) %> >
 |     61:           <%= select_f f, :compute_profile_id, ComputeProfile.visibles, :id, :name,
 |     62:             { :disable_button => _(HostsAndHostgroupsHelper::INHERIT_TEXT),
 |     63:               :disable_button_enabled => @host.hostgroup && @host.hostgroup_id_was.nil? && !params[:host][:compute_profile_id],
 |     64:               :user_set => params[:host] && params[:host][:compute_profile_id]
 |     65:             },
 |     66:             { :label => _("Compute profile"), :'data-url' => compute_resource_selected_hosts_path,
 |   app/views/hosts/_form.html.erb:63:in `block (2 levels) in _app_views_hosts__form_html_erb___2877621245529704098_63524720'
 |   app/helpers/layout_helper.rb:321:in `form_for'
 |   app/views/hosts/_form.html.erb:8:in `block in _app_views_hosts__form_html_erb___2877621245529704098_63524720'
 |   app/models/taxonomy.rb:66:in `block (2 levels) in as_taxonomy'
 |   app/models/concerns/foreman/thread_session.rb:147:in `as_location'
 |   app/models/taxonomy.rb:65:in `block in as_taxonomy'
 |   app/models/concerns/foreman/thread_session.rb:112:in `as_org'
 |   app/models/taxonomy.rb:64:in `as_taxonomy'
 |   app/views/hosts/_form.html.erb:6:in `_app_views_hosts__form_html_erb___2877621245529704098_63524720'
 |   app/views/hosts/clone.html.erb:3:in `_app_views_hosts_clone_html_erb__3090041382908852687_64038100'
 |   app/controllers/concerns/application_shared.rb:13:in `set_timezone'
 |   app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 |   lib/middleware/catch_json_parse_errors.rb:9:in `call'

There are a few accesses to nested parameters that won't have been passed in yet (e.g. params[:host][:compute_profile_id]) which don't check that params[:host] is trueish. This only happens when a host group is associated as there's a preceding check for @host.hostgroup.


Related issues 1 (0 open1 closed)

Related to Foreman - Bug #9591: Override puppet configuration on host level does not work if specified on host groupClosedShimon Shtein03/01/2015Actions
Actions #1

Updated by Dominic Cleal over 8 years ago

  • Related to Bug #9591: Override puppet configuration on host level does not work if specified on host group added
Actions #2

Updated by Shimon Shtein over 8 years ago

  • Assignee set to Shimon Shtein
Actions #3

Updated by The Foreman Bot over 8 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2597 added
  • Pull request deleted ()
Actions #4

Updated by Shimon Shtein over 8 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF