Bug 1813073

Summary: Bad output when using cves member outside of a report_row call
Product: Red Hat Satellite Reporter: Jessica Hanley <jhanley>
Component: ReportingAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.5.0CC: mhulan, oprazak
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-19 10:09:17 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 Jessica Hanley 2020-03-12 21:11:25 UTC
Description of problem:

When creating custom report template, this code

<%- load_hosts(search: input('Hosts filter'), includes: [:operatingsystem, :applicable_errata, :lifecycle_environment]).each_record do |host| -%>
<%-   host_applicable_errata_filtered(host, input('Errata filter')).each do |erratum| -%>
<%= host.name %>
<%= erratum.errata_id %>
<%= erratum.cves %>
<%-   end -%>
<%- end -%>

produces this output:

denjht3.usersys.redhat.com
RHBA-2019:3977
#<Katello::ErratumCve::ActiveRecord_Associations_CollectionProxy:0x00007f3ab9067a70>

However, this code

<%- load_hosts(search: input('Hosts filter'), includes: [:operatingsystem, :applicable_errata, :lifecycle_environment]).each_record do |host| -%>
<%-   host_applicable_errata_filtered(host, input('Errata filter')).each do |erratum| -%>
<%-     report_row(
          'Host': host.name,
          'Erratum': erratum.errata_id,
          'CVEs': erratum.cves
        ) -%>
<%-   end -%>
<%- end -%>
<%= report_render -%>

produces this output:

Host,Erratum,CVEs
denjht3.usersys.redhat.com,RHBA-2020:0365,""
denjht3.usersys.redhat.com,RHSA-2019:4190,"4804,4805"

In the first example, the erratum.cves call produces output like this:

#<Katello::ErratumCve::ActiveRecord_Associations_CollectionProxy:0x00007f3ab9067a70>

In the second example, the same call (embedded within a report_row method) produces output like this:

"4804,4805"

Note that the other members do work without being embedded within a report_row method; this problem is specific to the cves member.


Version-Release number of selected component (if applicable):

Satellite 6.5


How reproducible:

100%


Steps to Reproduce:
1.  Create a custom report with the code supplied above.
2.  Create a Hosts Filter and an Errata Filter, both with input type "User input".
3.  Click the preview button to view the report's results, or generate a report.

Actual results:

cves member gives values like this:

#<Katello::ErratumCve::ActiveRecord_Associations_CollectionProxy:0x00007f3ab9067a70>


Expected results:

cves member should give values like this, even when not embedded within a report_row method:

"4804,4805"

Comment 3 Marek Hulan 2020-03-19 10:09:17 UTC
This looks as a duplicate of BZ 1804335. We need to allow accessing the cve IDs. However as a workaround, this should work 

'CVEs': erratum.cves.map { |c| c.to_s }

closing as a dup, please reopen if I misunderstood

*** This bug has been marked as a duplicate of bug 1804335 ***