Bug 1546995

Summary: internal server error when accessing the "policy_events" attribute of the "vms" resource
Product: Red Hat CloudForms Management Engine Reporter: Martin Kourim <mkourim>
Component: APIAssignee: Gregg Tanzillo <gtanzill>
Status: CLOSED CURRENTRELEASE QA Contact: Martin Kourim <mkourim>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.8.0CC: obarenbo, simaishi, smallamp, yrudman
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: api:rest
Fixed In Version: 5.10.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1558030 1558032 (view as bug list) Environment:
Last Closed: 2018-07-30 14:44:04 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: 1558030, 1558032    

Description Martin Kourim 2018-02-20 10:08:14 UTC
Description of problem:
When accessing the "policy_events" attribute of the "vms" resource the request fails with bad request error:
{
    "error": {
        "kind": "internal_server_error",
        "message": "undefined local variable or method `id' for #<ActiveRecord::Relation []>\nDid you mean?  ids",
        "klass": "NameError"
    }
}


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


How reproducible:
100%


Steps to Reproduce:
GET /api/vms/:id?attributes=policy_events

Comment 3 CFME Bot 2018-03-16 15:47:29 UTC
New commit detected on ManageIQ/manageiq/master:

https://github.com/ManageIQ/manageiq/commit/adc676cb3bf11cd314aff3be55715adfc6a4eba8
commit adc676cb3bf11cd314aff3be55715adfc6a4eba8
Author:     Jillian Tullo <jtullo>
AuthorDate: Thu Feb 22 07:29:16 2018 -0500
Commit:     Jillian Tullo <jtullo>
CommitDate: Thu Feb 22 07:29:16 2018 -0500

    Fix policy_events relationship on VmOrTemplate

    The policy_events relationship currently results in an internal server error because it is referencing "id" which is not valid

    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1546995

 app/models/vm_or_template.rb | 2 +-
 spec/models/vm_or_template_spec.rb | 8 +
 2 files changed, 9 insertions(+), 1 deletion(-)

Comment 7 Dave Johnson 2018-07-30 14:44:04 UTC
Closing this as its already been verified in two z-streams and has test coverage around it.