Bug 1456742

Summary: Failed while launching imported report based on Chargeback for Projects via REST API.
Product: Red Hat CloudForms Management Engine Reporter: Neha Chugh <nchugh>
Component: ReportingAssignee: Gregg Tanzillo <gtanzill>
Status: CLOSED CURRENTRELEASE QA Contact: Nandini Chandra <nachandr>
Severity: medium Docs Contact:
Priority: high    
Version: 5.7.0CC: fdupont, jhardy, obarenbo, simaishi
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.9.0   
Hardware: All   
OS: All   
Whiteboard: chargeback:api:import
Fixed In Version: 5.9.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1458810 1460396 (view as bug list) Environment:
Last Closed: 2018-03-06 14:37:38 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:
Bug Depends On:    
Bug Blocks: 1458810, 1460396    
Attachments:
Description Flags
importing and launching the report none

Description Neha Chugh 2017-05-30 09:52:30 UTC
Description of problem:
While launching imported report based on Chargeback for Projects based on API. 


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

How reproducible:
Always

Steps to Reproduce:

1- Choose an arbitrary report in the WebUI and test it to ensure it works.
2- Export this report as a YAML file through WebUI, convert it to JSON, and add extra sections so it looks like the example here : https://github.com/ManageIQ/manageiq_docs/blob/master/api/reference/reports.adoc
3- Import the JSON report through API with a curl POST command
4 - Try to launch a new report with this imported report

Actual results:
It failed with below exception:

{"href":"https://10.74.130.103/api/tasks/4253000000002182","id":4253000000002182,"name":"Generate Report: 'cb_report'","state":"Finished","status":"Error","message":"undefined method `find' for ChargebackContainerProject:Class","userid":"system","created_on":"2017-05-30T09:10:00Z","updated_on":"2017-05-30T09:10:05Z"}


Expected results:
Report should be launched.


Additional info:
It is working for other reports but not for report based on Chargeback projects.

Also find the text file which includes the related URLs that are hit and the corresponding output.

Comment 2 Neha Chugh 2017-05-30 09:56:04 UTC
Created attachment 1283382 [details]
importing and launching the report

Comment 3 Gregg Tanzillo 2017-05-30 21:13:57 UTC
Looking at the json I can see the in the conversion from yaml, ruby symbols in the the serialized hash "db_options" were converted to strings. However, the report generator is expecting symbols. This is what's causing the failure. 

I don't think it's possible to preserve symbols in json so the reporting conde may need to support both. I will need to investigate further.

Comment 5 CFME Bot 2017-06-02 03:06:32 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/ef760a7872ff28fef131ae582682ca8db0d4b8ea

commit ef760a7872ff28fef131ae582682ca8db0d4b8ea
Author:     Gregg Tanzillo <gtanzill>
AuthorDate: Thu Jun 1 13:59:27 2017 -0400
Commit:     Gregg Tanzillo <gtanzill>
CommitDate: Thu Jun 1 13:59:27 2017 -0400

    Ensure report columns serialized as hashes have symbolized keys before importing
    
    This fixes a bug where a report imported via the Rest API, as json, fails to generate because the keys
    in columns serialized as hashes are received as strings.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1456742

 app/models/miq_report/import_export.rb       |  3 +++
 spec/models/miq_report/import_export_spec.rb | 20 +++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

Comment 6 Neha Chugh 2017-06-02 13:58:55 UTC
As discussed with Greg on gitter, the two shared PR files, we need to apply changes only on one file i.e. import_export.rb not to the import_export_spec.rb file as this file is missing at downstream.

Will test the changes as suggested by greg and will update the result accordingly.

Regards,
Neha Chugh

Comment 9 Nandini Chandra 2017-12-19 15:40:40 UTC
Verified in 5.9.0.13