theforeman / foreman_puppet

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

Undefined method `environment’ for #<ForemanPuppet::ConfigGroup:0x00005585340b0e50> when selecting Puppet Config group in UI #357

Closed ohgaryoh closed 1 year ago

ohgaryoh commented 1 year ago

When selecting a config group under Configure > Config Groups the following error message is shown:

undefined method `environment’ for #ForemanPuppet::ConfigGroup:0x00005585340b0e50

Foreman and Proxy versions: 3.5.3

Foreman and Proxy plugin versions:

foreman-tasks 7.1.1 foreman_ansible 10.4.2 foreman_discovery 22.0.2 foreman_openscap 6.0.0 foreman_puppet 5.1.2 foreman_remote_execution 8.2.0 katello 4.7.5 Distribution and version:

Rocky 8.8

Other relevant data: We have recently restored a new Rocky 8 server with the Forman/Katello backup of our Centos 7 sever which ran F 3.3 and K 4.5 using foreman backup and restore, so that we can be on a supported OS and Foreman/Katello version. We are able to use the hammer shell to make changes to our config groups. This is an issue that has shown up and would like help resolving it.

I have posted this on the support forum on Foreman and it was suggested that I open a request here as well.

From foreman-rake errors:fetch_log request_id=084acb5d command:

2023-06-15T14:09:22 [I|app|084acb5d] Started GET "/foreman_puppet/config_groups/3-Linux-Prod/edit" for 10.31.27.186 at 2023-06-15 14:09:22 -0400
2023-06-15T14:09:22 [I|app|084acb5d] Processing by ForemanPuppet::ConfigGroupsController#edit as HTML
2023-06-15T14:09:22 [I|app|084acb5d]   Parameters: {"id"=>"3-Linux-Prod"}
2023-06-15T14:09:22 [I|app|084acb5d]   Rendered /usr/share/gems/gems/foreman_puppet-5.1.2/app/views/foreman_puppet/config_groups/edit.html.erb within layouts/application (Duration: 31.3ms | Allocations: 12986)
2023-06-15T14:09:22 [I|app|084acb5d]   Rendered layout layouts/application.html.erb (Duration: 31.6ms | Allocations: 13039)
2023-06-15T14:09:22 [W|app|084acb5d] undefined method `environment' for #<ForemanPuppet::ConfigGroup:0x00005585340b0e50>
2023-06-15T14:09:22 [I|app|084acb5d] Backtrace for 'undefined method `environment' for #<ForemanPuppet::ConfigGroup:0x00005585340b0e50>' error (ActionView::Template::Error): undefined method `environment' for #<ForemanPuppet::ConfigGroup:0x00005585340b0e50>
 084acb5d | /usr/share/gems/gems/activemodel-6.1.7.3/lib/active_model/attribute_methods.rb:469:in `method_missing'
 084acb5d | /usr/share/gems/gems/foreman_puppet-5.1.2/app/views/foreman_puppet/puppetclasses/_selected_classes.html.erb:1:in `_92b4407d3f6ff6500e78d5e2b1d20643'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/base.rb:247:in `public_send'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/base.rb:247:in `_run'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:154:in `block in render'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:205:in `instrument'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:345:in `instrument_render_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:152:in `render'
 084acb5d | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/collection_renderer.rb:189:in `block in collection_with_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/collection_renderer.rb:70:in `block in each_with_info'
 084acb5d | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/relation/delegation.rb:88:in `each'
 084acb5d | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/relation/delegation.rb:88:in `each'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/collection_renderer.rb:70:in `each_with_info'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/collection_renderer.rb:88:in `each_with_info'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/collection_renderer.rb:180:in `each'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/collection_renderer.rb:180:in `map'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/collection_renderer.rb:180:in `collection_with_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/collection_renderer.rb:162:in `block (2 levels) in render_collection'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/partial_renderer/collection_caching.rb:21:in `cache_collection_render'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/collection_renderer.rb:161:in `block in render_collection'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `block in instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `instrument'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/collection_renderer.rb:147:in `render_collection'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/collection_renderer.rb:119:in `render_collection_with_partial'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/renderer.rb:72:in `render_partial_to_object'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/renderer.rb:27:in `render_to_object'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/renderer.rb:22:in `render'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/helpers/rendering_helper.rb:38:in `block in render'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/base.rb:273:in `in_rendering_context'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/helpers/rendering_helper.rb:34:in `render'
 084acb5d | /usr/share/gems/gems/foreman_puppet-5.1.2/app/views/foreman_puppet/puppetclasses/_class_selection.html.erb:13:in `_563c2e0bb10d7c35da3843d7b7d64f8f'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/base.rb:247:in `public_send'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/base.rb:247:in `_run'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:154:in `block in render'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:205:in `instrument'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:345:in `instrument_render_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:152:in `render'
 084acb5d | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/partial_renderer.rb:285:in `block in render_partial_template'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `block in instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `instrument'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/partial_renderer.rb:280:in `render_partial_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/partial_renderer.rb:271:in `render'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/renderer.rb:53:in `render_partial'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/helpers/rendering_helper.rb:45:in `render'
 084acb5d | /usr/share/gems/gems/foreman_puppet-5.1.2/app/views/foreman_puppet/config_groups/_form.html.erb:5:in `block in _cd5a3ab64ab4e7e2144cf2ab85ed669c'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/helpers/capture_helper.rb:45:in `block in capture'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/helpers/capture_helper.rb:209:in `with_output_buffer'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/helpers/capture_helper.rb:45:in `capture'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/helpers/form_helper.rb:450:in `form_for'
 084acb5d | /usr/share/foreman/app/helpers/form_helper.rb:287:in `form_for'
 084acb5d | /usr/share/gems/gems/foreman_puppet-5.1.2/app/views/foreman_puppet/config_groups/_form.html.erb:1:in `_cd5a3ab64ab4e7e2144cf2ab85ed669c'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/base.rb:247:in `public_send'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/base.rb:247:in `_run'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:154:in `block in render'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:205:in `instrument'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:345:in `instrument_render_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:152:in `render'
 084acb5d | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/partial_renderer.rb:285:in `block in render_partial_template'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `block in instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `instrument'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/partial_renderer.rb:280:in `render_partial_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/partial_renderer.rb:271:in `render'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/renderer.rb:53:in `render_partial'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/helpers/rendering_helper.rb:45:in `render'
 084acb5d | /usr/share/gems/gems/foreman_puppet-5.1.2/app/views/foreman_puppet/config_groups/edit.html.erb:3:in `_76565c7a2fc9dc9125190dcaee1c1fa3'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/base.rb:247:in `public_send'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/base.rb:247:in `_run'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:154:in `block in render'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:205:in `instrument'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:345:in `instrument_render_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/template.rb:152:in `render'
 084acb5d | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/template_renderer.rb:61:in `block (2 levels) in render_template'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `block in instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `instrument'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/template_renderer.rb:56:in `block in render_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/template_renderer.rb:71:in `block in render_with_layout'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `block in instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `instrument'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/template_renderer.rb:70:in `render_with_layout'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/template_renderer.rb:55:in `render_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/template_renderer.rb:11:in `render'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/renderer/renderer.rb:29:in `render_to_object'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/rendering.rb:117:in `block in _render_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/base.rb:273:in `in_rendering_context'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/rendering.rb:116:in `_render_template'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/streaming.rb:218:in `_render_template'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/rendering.rb:103:in `render_to_body'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/rendering.rb:52:in `render_to_body'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/renderers.rb:142:in `render_to_body'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/rendering.rb:25:in `render'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/rendering.rb:36:in `render'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
 084acb5d | /usr/share/ruby/benchmark.rb:308:in `realtime'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/core_ext/benchmark.rb:14:in `ms'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:46:in `block in render'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:86:in `cleanup_view_runtime'
 084acb5d | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:45:in `render'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/implicit_render.rb:35:in `default_render'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/base.rb:228:in `process_action'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/rendering.rb:30:in `process_action'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 084acb5d | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 084acb5d | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 084acb5d | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 084acb5d | /usr/share/gems/gems/audited-5.0.2/lib/audited/sweeper.rb:16:in `around'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 084acb5d | /usr/share/gems/gems/audited-5.0.2/lib/audited/sweeper.rb:16:in `around'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:137:in `run_callbacks'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/callbacks.rb:41:in `process_action'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/rescue.rb:22:in `process_action'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `block in instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `instrument'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:33:in `process_action'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
 084acb5d | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/base.rb:165:in `process'
 084acb5d | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/rendering.rb:39:in `process'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal.rb:190:in `dispatch'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal.rb:254:in `dispatch'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:33:in `serve'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:50:in `block in serve'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:32:in `each'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:32:in `serve'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:842:in `call'
 084acb5d | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/engine.rb:539:in `call'
 084acb5d | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/railtie.rb:207:in `public_send'
 084acb5d | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/railtie.rb:207:in `method_missing'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/mapper.rb:20:in `block in <class:Constraints>'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/mapper.rb:49:in `serve'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:50:in `block in serve'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:32:in `each'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:32:in `serve'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:842:in `call'
 084acb5d | /usr/share/gems/gems/katello-4.7.5/lib/katello/middleware/organization_created_enforcer.rb:18:in `call'
 084acb5d | /usr/share/gems/gems/katello-4.7.5/lib/katello/middleware/event_daemon.rb:10:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 084acb5d | /usr/share/gems/gems/apipie-dsl-2.5.0/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
 084acb5d | /usr/share/gems/gems/apipie-rails-0.8.2/lib/apipie/static_dispatcher.rb:68:in `call'
 084acb5d | /usr/share/gems/gems/apipie-rails-0.8.2/lib/apipie/extractor/recorder.rb:137:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 084acb5d | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in `call'
 084acb5d | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
 084acb5d | /usr/share/gems/gems/apipie-rails-0.8.2/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/tempfile_reaper.rb:15:in `call'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/etag.rb:27:in `call'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/conditional_get.rb:27:in `call'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/head.rb:12:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/http/permissions_policy.rb:22:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/http/content_security_policy.rb:19:in `call'
 084acb5d | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/session/abstract/id.rb:266:in `context'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/session/abstract/id.rb:260:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/cookies.rb:697:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:98:in `run_callbacks'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
 084acb5d | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/rack/logger.rb:37:in `call_app'
 084acb5d | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/rack/logger.rb:28:in `call'
 084acb5d | /usr/share/gems/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 084acb5d | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/request_id.rb:26:in `call'
 084acb5d | /usr/share/gems/gems/katello-4.7.5/lib/katello/prevent_json_parsing.rb:12:in `call'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/method_override.rb:24:in `call'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/runtime.rb:22:in `call'
 084acb5d | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/executor.rb:14:in `call'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/sendfile.rb:110:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/ssl.rb:77:in `call'
 084acb5d | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
 084acb5d | /usr/share/gems/gems/secure_headers-6.5.0/lib/secure_headers/middleware.rb:11:in `call'
 084acb5d | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/engine.rb:539:in `call'
 084acb5d | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/railtie.rb:207:in `public_send'
 084acb5d | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/railtie.rb:207:in `method_missing'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:74:in `block in call'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `each'
 084acb5d | /usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `call'
 084acb5d | /usr/share/gems/gems/puma-5.6.5/lib/puma/configuration.rb:252:in `call'
 084acb5d | /usr/share/gems/gems/puma-5.6.5/lib/puma/request.rb:77:in `block in handle_request'
 084acb5d | /usr/share/gems/gems/puma-5.6.5/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
 084acb5d | /usr/share/gems/gems/puma-5.6.5/lib/puma/request.rb:76:in `handle_request'
 084acb5d | /usr/share/gems/gems/puma-5.6.5/lib/puma/server.rb:443:in `process_client'
 084acb5d | /usr/share/gems/gems/puma-5.6.5/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
 084acb5d | /usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2023-06-15T14:09:22 [I|app|084acb5d]   Rendered common/500.html.erb within layouts/application (Duration: 3.4ms | Allocations: 2162)
2023-06-15T14:09:22 [I|app|084acb5d]   Rendered layouts/base.html.erb (Duration: 4.8ms | Allocations: 4228)
2023-06-15T14:09:22 [I|app|084acb5d]   Rendered layout layouts/application.html.erb (Duration: 11.9ms | Allocations: 9898)
2023-06-15T14:09:22 [I|app|084acb5d] Completed 500 Internal Server Error in 58ms (Views: 12.6ms | ActiveRecord: 5.0ms | Allocations: 25927)

Foreman version: 3.5.3 Plugins:

Thank you for the help in advance

nadjaheitmann commented 1 year ago

It's probably due to this commit. Thanks for reporting.

ohgaryoh commented 1 year ago

It's probably due to this commit. Thanks for reporting.

Great, thank you for looking into this. Is there anything I can do on my end or wait until an update is pushed out?

nadjaheitmann commented 1 year ago

You could revert that commit on your system for now until there is a fix.

ohgaryoh commented 1 year ago

Found the file: /usr/share/gems/gems/foreman_puppet-5.1.2/app/views/foreman_puppet/puppetclasses/_selected_classes.html.erb

edited it to the previous commit, restarted services and it is working now. Thank you for your help!

nadjaheitmann commented 1 year ago

@ekohl Do you have any idea how to fix this properly?

ekohl commented 1 year ago

My feeling is that there's too much logic in the template, so first unwrap it. What follows is a written down version of my thought process.

So the code:

https://github.com/theforeman/foreman_puppet/blob/936b4688eea4eaf562296f24a1eb11c61b11e74b/app/views/foreman_puppet/puppetclasses/_selected_classes.html.erb#L1

That's very long, so take the relevant bit:

'unavailable' unless klass.environments.include?(obj.environment.present? ? obj.environment : @environment)

My first step would be to extract that:

<%-
class_in_environment = klass.environments.include?(obj.environment.present? ? obj.environment : @environment)
-%>
<%= content_tag :li, id: "selected_puppetclass_#{klass.id}", class: [dom_class(klass, 'selected'), cycle('even', 'odd'), ('unavailable' unless class_in_environment)] do %>

This hasn't changed any functionality, but it's easier to modify. I chose a multi line block since it's easier to modify later.

Then I want to understand where it's called: https://github.com/theforeman/foreman_puppet/blob/936b4688eea4eaf562296f24a1eb11c61b11e74b/app/views/foreman_puppet/puppetclasses/_class_selection.html.erb#L13-L22

There we see we can look at the resource type and there already is an exception for the config group resource type. You can probably use this. I don't think config groups really are linked to an environment so I'm not sure what the logic should be. You can probably revert to using @environment when the resource type is :config_group, which would likely prevent crashes. However, I'm not sure @environment is even set. It's not passed as a local so it may always be nil. I'd also check that.

Does that help?

nadjaheitmann commented 1 year ago

@ekohl Makes sense, thank you a lot! I will take a closer look at this.

ares commented 1 year ago

A quick hack would be to just wrap environment in try, e.g. this seems to do the trick

<%= content_tag :li, id: "selected_puppetclass_#{klass.id}", class: [dom_class(klass, 'selected'), cycle('even', 'odd'), ('unavailable' unless klass.environments.include?(obj.try(:environment).present? ? obj.try(:environment) : @environment))] do %>

That would make this partial compatible with also object that are not linked to the environment, which I think was the original logic of this condition.

ekohl commented 1 year ago

If that works, isn't obj.try(:environment).presence || @environment the same? Or at least the second .try is redundant because we already know it responds to .environment, so obj.try(:environment).present? ? obj.environment : @environment).