Bug #36271
closedIn report template, the host_latest_applicable_rpm_version global method results in error and report to not generate
Description
Example:
Using the method like so ''Latest Available Kernel': host_latest_applicable_rpm_version(host, 'kernel')' causes the error 'undefined method `nvra' for nil:NilClass'
Further information in /var/log/foreman/production.log:
2023-04-03T14:22:14 [E|app|8e502369] Error performing TemplateRenderJob (Job ID: a4be94d9-06f7-401c-9a03-79668dbf7ff3) from Dynflow(default) in 57.76ms: NoMethodError (undefined method `nvra' for nil:NilClass):
/usr/share/gems/gems/katello-4.7.4/app/lib/katello/concerns/base_template_scope_extensions.rb:164:in `host_latest_applicable_rpm_version'
/usr/share/gems/gems/safemode-1.3.7/lib/safemode/scope.rb:37:in `method_missing'
Host - Server compliance report:70:in `block in bind'
/usr/share/gems/gems/activerecord-6.1.7.2/lib/active_record/relation/batches/batch_enumerator.rb:40:in `block (2 levels) in each_record'
/usr/share/gems/gems/activerecord-6.1.7.2/lib/active_record/relation/batches/batch_enumerator.rb:40:in `each'
/usr/share/gems/gems/activerecord-6.1.7.2/lib/active_record/relation/batches/batch_enumerator.rb:40:in `block in each_record'
/usr/share/gems/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:245:in `block in in_batches'
/usr/share/gems/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:229:in `loop'
/usr/share/gems/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:229:in `in_batches'
/usr/share/gems/gems/activerecord-6.1.7.2/lib/active_record/relation/batches/batch_enumerator.rb:39:in `each'
/usr/share/gems/gems/activerecord-6.1.7.2/lib/active_record/relation/batches/batch_enumerator.rb:39:in `each_record'
/usr/share/gems/gems/safemode-1.3.7/lib/safemode/jail.rb:31:in `method_missing'