Bug 1482393

Summary: Internal server error for GET /api/compliance/policies/:id/tailoring when tailoring file is not associated
Product: Red Hat Satellite Reporter: Nikhil Kathole <nkathole>
Component: SCAP PluginAssignee: Ondřej Pražák <oprazak>
Status: CLOSED ERRATA QA Contact: Nikhil Kathole <nkathole>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: bbuckingham, ehelms, mhulan, oprazak, sjagtap, tstrachota
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foreman-openscap-0.7.5 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:51:07 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:
Attachments:
Description Flags
log in production.log file none

Description Nikhil Kathole 2017-08-17 07:25:13 UTC
Created attachment 1314582 [details]
log in production.log file

Description of problem: API GET /api/compliance/policies/:id/tailoring results in 

"undefined method `scap_file' for nil:NilClass"

when tailoring file is not associated with compliance policy and log file shows 500 Internal server error.

Version-Release number of selected component (if applicable): sat 6.3 snap 11


How reproducible: always


Steps to Reproduce:
1. Create compliance policy with scap content (do not associate tailoring file) 
2.  curl -s -X GET -k -u admin:<password>  'https://$HOST/api/v2/compliance/policies/1/tailoring'

Actual results:
Results in 

{
  "error": {"message":"undefined method `scap_file' for nil:NilClass"}
}

and tail -f /var/log/foreman/production.log shows Internal server error 500.

Expected results:

Error should get handled and proper message should be displayed.

Additional info:
For sat 6.3 snap 11, GET 'https://$HOST/api/compliance/policies/1/tailoring' will not work. Try GET 'https://$HOST/api/v2/compliance/policies/1/tailoring'.
Refer BZ #1482383.

Comment 2 Ondřej Pražák 2017-08-21 08:25:33 UTC
Created redmine issue http://projects.theforeman.org/issues/20656 from this bug

Comment 3 Satellite Program 2017-08-21 10:15:18 UTC
Upstream bug assigned to oprazak

Comment 4 Satellite Program 2017-08-21 10:15:22 UTC
Upstream bug assigned to oprazak

Comment 5 Satellite Program 2017-08-25 16:15:00 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/20656 has been resolved.

Comment 6 Nikhil Kathole 2017-09-10 06:39:49 UTC
VERIFIED

Version Tested:
Satellite-6.3 Snap 15

steps:
1. Created scap policy without assigning tailoring file
2. curl -s -X GET -k -u admin:password  'https://$HOST/api/v2/compliance/policies/2/tailoring'

Shows valid message as 

{"error":{"message":"No Tailoring file assigned for policy with id 2"}}

Comment 7 Satellite Program 2018-02-21 16:51:07 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, 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-2018:0336