Undefined method `assign_single_environment' for nil:NilClass

Problem:
Hi
i’ve got this problem, some undefined time(really don’t remember how long) but anytime when i’m trying to edit any host(like Hosts → All hosts → choose any host → Edit) and after pressing submit this error affect.
i hope that this problem will disappear after upgrading to 3.7.0 from 3.6, but it still affect .

Expected outcome:

Foreman and Proxy versions:
foreman-3.7.0
foreman-proxy-3.7.0

Foreman and Proxy plugin versions:

  • foreman-tasks 8.1.1
  • foreman_ansible 12.0.5
  • foreman_default_hostgroup 7.0.0
  • foreman_fog_proxmox 0.14.2
  • foreman_puppet 6.0.0
  • foreman_remote_execution 10.0.5
  • katello 4.9.1

Distribution and version:
Foreman: Oracle Linux 8.8
Clients: Oracle Linux 8.6/8.8/9.0, CentOS 7.7

Rake:
2023-08-08T11:24:35 [I|app|c4889029] Started PATCH “/hosts/142” for IP at 2023-08-08 11:24:35 +0300
2023-08-08T11:24:35 [I|app|c4889029] Processing by HostsController#update as /
2023-08-08T11:24:35 [I|app|c4889029] Parameters: {“utf8”=>“✓”, “authenticity_token”=>“SOME_TOKEN”,
“host”=>{“name”=>“4talk-pres.DOMAIN”, “hostgroup_id”=>“4”, “puppet_attributes”=>{“environment_id”=>“1”}, “puppet_proxy_id”=>“1”, “puppet_ca_proxy_id”=>“1”, “host_ans
ible_roles_attributes”=>{“0”=>{“id”=>“5”, “ansible_role_id”=>“32”, “position”=>“1”, "destroy"=>“false”}}, “puppetclass_ids”=>[“”], “managed”=>“false”, “progress_report_id”=>“[FI
LTERED]”, “interfaces_attributes”=>{“0”=>{"destroy"=>“0”, “mac”=>“0e:79:c1:15:d4:05”, “identifier”=>“eth0”, “name”=>“4talk-pres”, “domain_id”=>“1”, “subnet_id”=>“”, “ip
“=>“IP”, “ip6”=>””, “managed”=>“1”, “primary”=>“1”, “provision”=>“1”, “execution”=>“1”, “tag”=>“”, “attached_to”=>“”, “id”=>“324”}}, “is_owned_by”=>“4-Users”, “enabled”
=>“1”, “model_id”=>“2”, “comment”=>“”, “overwrite”=>“false”}, “id”=>“142”}
2023-08-08T11:24:35 [W|api|c4889029] param host[puppetclass
*] has been deprecated in favor of host[puppet_attributes][puppetclass
*]
2023-08-08T11:24:35 [W|app|c4889029] undefined method assign_single_environment' for nil:NilClass 2023-08-08T11:24:35 [I|app|c4889029] Backtrace for 'undefined method assign_single_environment’ for nil:NilClass’ error (NoMethodError): undefined method assign_single_environm ent' for nil:NilClass c4889029 | /usr/share/gems/gems/katello-4.9.1/app/models/katello/concerns/host_managed_extensions.rb:14:in update’
c4889029 | /usr/share/foreman/app/controllers/hosts_controller.rb:118:in block in update' c4889029 | /usr/share/foreman/app/models/taxonomy.rb:73:in block in no_taxonomy_scope’
c4889029 | /usr/share/foreman/app/models/taxonomy.rb:80:in block (2 levels) in as_taxonomy' c4889029 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:195:in as_location’
c4889029 | /usr/share/foreman/app/models/taxonomy.rb:79:in block in as_taxonomy' c4889029 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:154:in as_org’
c4889029 | /usr/share/foreman/app/models/taxonomy.rb:78:in as_taxonomy' c4889029 | /usr/share/foreman/app/models/taxonomy.rb:72:in no_taxonomy_scope’
c4889029 | /usr/share/foreman/app/controllers/hosts_controller.rb:115:in update' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/basic_implicit_render.rb:6:in send_action’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/base.rb:228:in process_action' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/rendering.rb:30:in process_action’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/callbacks.rb:42:in block in process_action' c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:117:in block in run_callbacks’
c4889029 | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in set_timezone' c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in block in run_callbacks’
c4889029 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in clear_thread' c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in block in run_callbacks’
c4889029 | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in set_topbar_sweeper_controller' c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in block in run_callbacks’
c4889029 | /usr/share/gems/gems/audited-5.3.3/lib/audited/sweeper.rb:16:in around' c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in block in run_callbacks’
c4889029 | /usr/share/gems/gems/audited-5.3.3/lib/audited/sweeper.rb:16:in around' c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in block in run_callbacks’
c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:137:in run_callbacks' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/callbacks.rb:41:in process_action’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/rescue.rb:22:in process_action' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:34:in block in process_action’
c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in block in instrument' c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications/instrumenter.rb:24:in instrument’
c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in instrument' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:33:in process_action’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/params_wrapper.rb:249:in process_action' c4889029 | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/railties/controller_runtime.rb:27:in process_action’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/base.rb:165:in process' c4889029 | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/rendering.rb:39:in process’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal.rb:190:in dispatch' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal.rb:254:in dispatch’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:50:in dispatch' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:33:in serve’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:50:in block in serve' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:32:in each’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:32:in serve' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:842:in call’
c4889029 | /usr/share/gems/gems/katello-4.9.1/lib/katello/middleware/organization_created_enforcer.rb:18:in call' c4889029 | /usr/share/gems/gems/katello-4.9.1/lib/katello/middleware/event_daemon.rb:10:in call’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call’
c4889029 | /usr/share/gems/gems/apipie-dsl-2.5.0/lib/apipie_dsl/static_dispatcher.rb:67:in call' c4889029 | /usr/share/gems/gems/apipie-rails-1.1.0/lib/apipie/static_dispatcher.rb:68:in call’
c4889029 | /usr/share/gems/gems/apipie-rails-1.1.0/lib/apipie/extractor/recorder.rb:139:in call' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call' c4889029 | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in call’
c4889029 | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in call' c4889029 | /usr/share/gems/gems/apipie-rails-1.1.0/lib/apipie/middleware/checksum_in_headers.rb:27:in call’
c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/tempfile_reaper.rb:15:in call' c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/etag.rb:27:in call’
c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/conditional_get.rb:40:in call' c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/head.rb:12:in call’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/http/permissions_policy.rb:22:in call' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/http/content_security_policy.rb:19:in call’
c4889029 | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in call' c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:266:in context’
c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:260:in call' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/cookies.rb:697:in call’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/callbacks.rb:27:in block in call' c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:98:in run_callbacks’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/callbacks.rb:26:in call' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in call’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/debug_exceptions.rb:29:in call' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/show_exceptions.rb:33:in call’
c4889029 | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/rack/logger.rb:37:in call_app' c4889029 | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/rack/logger.rb:28:in call’
c4889029 | /usr/share/gems/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13:in call' c4889029 | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in call’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/remote_ip.rb:81:in call' c4889029 | /usr/share/gems/gems/request_store-1.5.1/lib/request_store/middleware.rb:19:in call’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/request_id.rb:26:in call' c4889029 | /usr/share/gems/gems/katello-4.9.1/lib/katello/prevent_json_parsing.rb:12:in call’
c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/method_override.rb:24:in call' c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/runtime.rb:22:in call’
c4889029 | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in call' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/executor.rb:14:in call’
c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/sendfile.rb:110:in call' c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/ssl.rb:77:in call’
c4889029 | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/host_authorization.rb:142:in call' c4889029 | /usr/share/gems/gems/secure_headers-6.5.0/lib/secure_headers/middleware.rb:11:in call’
c4889029 | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/engine.rb:539:in call' c4889029 | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/railtie.rb:207:in public_send’
c4889029 | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/railtie.rb:207:in method_missing' c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/urlmap.rb:74:in block in call’
c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/urlmap.rb:58:in each' c4889029 | /usr/share/gems/gems/rack-2.2.7/lib/rack/urlmap.rb:58:in call’
c4889029 | /usr/share/gems/gems/puma-6.2.2/lib/puma/configuration.rb:270:in call' c4889029 | /usr/share/gems/gems/puma-6.2.2/lib/puma/request.rb:98:in block in handle_request’
c4889029 | /usr/share/gems/gems/puma-6.2.2/lib/puma/thread_pool.rb:340:in with_force_shutdown' c4889029 | /usr/share/gems/gems/puma-6.2.2/lib/puma/request.rb:97:in handle_request’
c4889029 | /usr/share/gems/gems/puma-6.2.2/lib/puma/server.rb:431:in process_client' c4889029 | /usr/share/gems/gems/puma-6.2.2/lib/puma/server.rb:233:in block in run’
c4889029 | /usr/share/gems/gems/puma-6.2.2/lib/puma/thread_pool.rb:147:in block in spawn_thread' c4889029 | /usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in block in create_with_logging_context’
2023-08-08T11:24:35 [I|app|c4889029] Rendered common/500.html.erb (Duration: 6.3ms | Allocations: 6239)
2023-08-08T11:24:35 [I|app|c4889029] Completed 500 Internal Server Error in 43ms (Views: 6.7ms | ActiveRecord: 6.1ms | Allocations: 17829)

cc @jeremylenz that should be in your area of expertise :wink:

This looks like Bug #36462: Can't add hostgroup to new host - Katello - Foreman

Some commits from dates between RC1 and GA are missing in Katello 4.9 and 4.9.1, and it appears this is one of them.

cc @wbclark