Bug 1540250 - internal server error when configuration_script is requested
Summary: internal server error when configuration_script is requested
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: API
Version: 5.9.0
Hardware: Unspecified
OS: Unspecified
medium
high
Target Milestone: GA
: 5.10.0
Assignee: Bill Wei
QA Contact: Parthvi Vala
URL:
Whiteboard: api:rest:services
Depends On:
Blocks: 1552271
TreeView+ depends on / blocked
 
Reported: 2018-01-30 15:48 UTC by Martin Kourim
Modified: 2019-02-11 14:03 UTC (History)
5 users (show)

Fixed In Version: 5.10.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1552271 (view as bug list)
Environment:
Last Closed: 2019-02-11 14:03:38 UTC
Category: ---
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Martin Kourim 2018-01-30 15:48:39 UTC
Description of problem:
When the "configuration_script" attribute is requested the request fails with internal server error:

{
    "error": {
        "kind": "internal_server_error",
        "message": "Association named 'configuration_script' was not found on Service; perhaps you misspelled it?",
        "klass": "ActiveRecord::AssociationNotFoundError"
    }
}

However the attribute is listed under the "relationships", so it should be possible to requested in the same way as all the other attributes.
See
OPTIONS /api/services


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


How reproducible:
100%


Steps to Reproduce:
1. create service, e.g.
POST /api/services
{ "name": "myservice01" }
2. request the "configuration_script" attribute
GET /api/services?expand=resources&attributes=configuration_script

Comment 2 Greg McCullough 2018-01-31 16:08:45 UTC
The virtual_has_one association 'configuration_script' is defined on the base service/service_template, this is required for reporting and possibly the API.

But the required methods are only available on the Ansible Service sub-classes.

I recommend that we create a empty method at the base service class which returns nil.

Comment 4 CFME Bot 2018-01-31 22:22:15 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/a6558c4723d83c2f00df8b26d4b0b7fd96751eaf

commit a6558c4723d83c2f00df8b26d4b0b7fd96751eaf
Author:     Bill Wei <bilwei>
AuthorDate: Wed Jan 31 16:25:33 2018 -0500
Commit:     Bill Wei <bilwei>
CommitDate: Wed Jan 31 16:33:02 2018 -0500

    Implement #configuration_script because of virtual_has_one relationship
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1540250

 app/models/service.rb       | 3 +++
 spec/models/service_spec.rb | 4 ++++
 2 files changed, 7 insertions(+)

Comment 6 Parthvi Vala 2019-01-03 07:23:02 UTC
FIXED. Verified on 5.10.0.30.


Note You need to log in before you can comment on or make changes to this bug.