Bug 2155392 - Host config report page raises "undefined method `[]' for nil:NilClass" error [NEEDINFO]
Summary: Host config report page raises "undefined method `[]' for nil:NilClass" error
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Ansible
Version: 6.11.4
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: 6.13.0
Assignee: Hao Chang Yu
QA Contact: addubey
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-12-21 05:07 UTC by Hao Chang Yu
Modified: 2023-08-01 17:19 UTC (History)
5 users (show)

Fixed In Version: rubygem-foreman_ansible-10.3.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-03 13:23:43 UTC
Target Upstream Version:
Embargoed:
pcreech: needinfo? (hyu)


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 35885 0 Normal New Bug 2155392 - Host config report page raises "undefined method `[]' for nil:NilClass" error 2022-12-21 05:17:22 UTC
Github foreman_ansible/pull/583 0 None None None 2022-12-21 08:22:21 UTC
Red Hat Issue Tracker SAT-14724 0 None None None 2023-01-05 16:24:03 UTC
Red Hat Product Errata RHSA-2023:2097 0 None None None 2023-05-03 13:23:53 UTC

Description Hao Chang Yu 2022-12-21 05:07:14 UTC
Description of problem:
Host config report page raises "undefined method `[]' for nil:NilClass" error if an ansible task reported multiple results per module action. For example, copy multiple files using loop.

-----------------------
[I|app|ae69c14e] Processing by ConfigReportsController#show as HTML
[I|app|ae69c14e]   Parameters: {"id"=>"18694"}
[I|app|ae69c14e]   Rendering config_reports/show.html.erb within layouts/application
[I|app|ae69c14e]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/views/foreman_ansible/config_reports/_ansible.html.erb (Duration: 12.4ms | Allocations: 7413)
[I|app|ae69c14e]   Rendered config_reports/show.html.erb within layouts/application (Duration: 34.6ms | Allocations: 15873)
[W|app|ae69c14e] undefined method `[]' for nil:NilClass
[I|app|ae69c14e] Backtrace for 'undefined method `[]' for nil:NilClass' error (ActionView::Template::Error): undefined method `[]' for nil:NilClass
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/helpers/foreman_ansible/ansible_reports_helper.rb:47:in `ansible_module_message'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/views/foreman_ansible/config_reports/_ansible.html.erb:24:in `block in _8af412795d3bd4ecb65c84004fd343a7'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation/delegation.rb:88:in `each'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation/delegation.rb:88:in `each'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-7.0.4.1/app/views/foreman_ansible/config_reports/_ansible.html.erb:18:in `_8af412795d3bd4ecb65c84004fd343a7'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/base.rb:274:in `_run'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:185:in `block in render'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:182:in `instrument'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:385:in `instrument_render_template'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:183:in `render'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/partial_renderer.rb:357:in `block in render_partial'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `block in instrument'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 ae69c14e | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `instrument'
-----------------------

How reproducible:
Easy

Steps to Reproduce:
1. Create a custom role which copy multiple files

mkdir /etc/ansible/roles/copy_ssh_keys/
mkdir /etc/ansible/roles/copy_ssh_keys/tasks

# Create this file
main.yml 
---
- name: Copy ssh keys
  copy:
    src: "/var/lib/foreman-proxy/ssh/{{ item }}"
    dest: "/root/.ssh"
    owner: root
    group: root
    mode: 0400
  with_items:
    - id_rsa_foreman_proxy
    - id_rsa_foreman_proxy.pub


2. Import the 'copy_ssh_keys' role to the Satellite and add it to a host
3. Trigger host ansible role job and wait until the job is finished successfully
4. Inspect the config report of this host job in Web UI -> Config Reports -> hostname

Actual results:
undefined method `[]' for nil:NilClass

Expected results:
Can show report without error.

Comment 1 Hao Chang Yu 2022-12-21 05:17:23 UTC
Create an upstream bug: https://projects.theforeman.org/issues/35885

Comment 3 Bryan Kearney 2023-01-16 12:03:15 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/35885 has been resolved.

Comment 9 Arzoo Singh 2023-04-14 17:22:24 UTC
Hi Team,

Can we have an update on below request from the customer   

Will a hotfix or patch be made available for Satellite 6.11.4.1?

If not, will the fix be added to a minor release for 6.11 or will we need to upgrade to a new major version?

Comment 11 errata-xmlrpc 2023-05-03 13:23:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.13 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:2097


Note You need to log in before you can comment on or make changes to this bug.