Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2256411

Summary: Getting "undefined method '#name' for NilClass::Jail (NilClass) (Safemode::NoMethodError)" error generating subscription report
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: ReportingAssignee: Ian Ballou <iballou>
Status: CLOSED ERRATA QA Contact: David Moore <damoore>
Severity: medium Docs Contact:
Priority: high    
Version: 6.14.0CC: ahumbe, chrobert, damoore, iballou, jbhatia, jlenz, rlavi, saydas, zhunting
Target Milestone: 6.15.0Keywords: Regression, Triaged, UserExperience, WorkAround
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foreman-3.9.1.5-1,foreman-3.9.1.6-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2272119 (view as bug list) Environment:
Last Closed: 2024-04-23 17:16:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Hao Chang Yu 2024-01-02 06:52:56 UTC
Description of problem:
Getting the following error in production.log when generating report for "Subscription - Entitlement Report".

-----------------
2024-01-02T05:06:18 [E|app|51ccadd6] Error performing TemplateRenderJob (Job ID: 3d7cbab7-b3b5-44f7-911f-2eb9bfd454f5) from Dynflow(default) in 467.55ms: Safemode::NoMethodError (undefined method '#name' for NilClass::Jail (NilClass)):
 51ccadd6 | /usr/share/gems/gems/safemode-1.3.8/lib/safemode/jail.rb:22:in `method_missing'
 51ccadd6 | Subscription - Entitlement Report:63:in `block (2 levels) in initialize'
 51ccadd6 | /usr/share/gems/gems/safemode-1.3.8/lib/safemode/jail.rb:31:in `each'
 51ccadd6 | /usr/share/gems/gems/safemode-1.3.8/lib/safemode/jail.rb:31:in `method_missing'
 51ccadd6 | Subscription - Entitlement Report:62:in `block in initialize'
 51ccadd6 | /usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:40:in `block (2 levels) in each_record'
 51ccadd6 | /usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:40:in `each'
 51ccadd6 | /usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:40:in `block in each_record'
 51ccadd6 | /usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:245:in `block in in_batches'
 51ccadd6 | /usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:229:in `loop'
 51ccadd6 | /usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:229:in `in_batches'
 51ccadd6 | /usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:39:in `each'
 51ccadd6 | /usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:39:in `each_record'
 51ccadd6 | /usr/share/gems/gems/safemode-1.3.8/lib/safemode/jail.rb:31:in `method_missing'
 51ccadd6 | Subscription - Entitlement Report:59:in `initialize'
 51ccadd6 | /usr/share/gems/gems/safemode-1.3.8/lib/safemode.rb:52:in `eval'
 51ccadd6 | /usr/share/gems/gems/safemode-1.3.8/lib/safemode.rb:52:in `eval'
 51ccadd6 | /usr/share/foreman/app/services/foreman/renderer/safe_mode_renderer.rb:7:in `render'
 51ccadd6 | /usr/share/foreman/app/services/foreman/renderer/base_renderer.rb:18:in `render'
 51ccadd6 | /usr/share/foreman/app/services/foreman/renderer.rb:46:in `render'
 51ccadd6 | /usr/share/foreman/app/models/template.rb:172:in `render'
 51ccadd6 | /usr/share/foreman/app/models/report_composer.rb:241:in `render'
 51ccadd6 | /usr/share/foreman/app/jobs/template_render_job.rb:12:in `block in perform'
 51ccadd6 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'
 51ccadd6 | /usr/share/foreman/app/jobs/template_render_job.rb:9:in `perform'
-----------------

How reproducible:
Easy

Steps to Reproduce:
1. Disable SCA in the Satellite
2. Configure virt-who and run it so that virt-who* hypervisor hosts will be created in Satellite.
3. Attach VDC subscription to the virt-who* hypervisor hosts.
4. Generate the "Subscription - Entitlement Report".

Actual results:
undefined method '#name' for NilClass::Jail (NilClass) (Safemode::NoMethodError)

Expected results:
Report can be generated successfully.


Additional info:
The error is caused by the following 2 lines in the "Subscription - Entitlement Report" template because virt-who* hypervisor hosts don't have any LCE or Content View.

-------------
<%-     report_row(
          'Host Name': host.name,
          'Organization': host.organization,
          'Lifecycle Environment': host.single_lifecycle_environment.name,  <===========
          'Content View': host.single_content_view.name,  <==============
          'Host Collections': host_collections_names(host),
-------------

Comment 1 Jeremy Lenz 2024-01-08 13:44:41 UTC
As a workaround you could clone the report template and add save navigation:

- 'Content View': host.single_content_view.name,
+ 'Content View': host.single_content_view&.name,

Comment 11 errata-xmlrpc 2024-04-23 17:16:48 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.15.0 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-2024:2010