Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1518297 - custom_actions of Generic Object Definition point to wrong resources
Summary: custom_actions of Generic Object Definition point to wrong resources
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
high
high
Target Milestone: GA
: 5.10.0
Assignee: Gregg Tanzillo
QA Contact: Martin Kourim
URL:
Whiteboard: api:generic_objects
Depends On:
Blocks: 1527564
TreeView+ depends on / blocked
 
Reported: 2017-11-28 15:04 UTC by Martin Kourim
Modified: 2018-06-21 20:40 UTC (History)
4 users (show)

Fixed In Version: 5.10.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1527564 (view as bug list)
Environment:
Last Closed: 2018-06-21 20:40:37 UTC
Category: ---
Cloudforms Team: CFME Core


Attachments (Terms of Use)

Description Martin Kourim 2017-11-28 15:04:08 UTC
Description of problem:
When listing the "custom_actions" attribute of the Generic Object Definition the "href" attributes points to wrong resources.

GET /api/generic_object_definitions/:id?attributes=custom_actions
...
"custom_actions": {
        "button_groups": [
            {
                "href": "https://<addr>/api/generic_object_definitions/34",
                ...
                "buttons": [
                    {
                        "href": "https://<addr>/api/generic_object_definitions/1",
                        ...

First href should be https://<addr>/api/custom_button_sets/34" and the second one should be "https://<addr>/api/custom_buttons/1"


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


How reproducible:
very


Steps to Reproduce:
1. create Generic Object Definition
2. add Button Group and Button
3. GET /api/generic_object_definitions/:id?attributes=custom_actions

Comment 2 Martin Kourim 2017-11-28 15:52:02 UTC
Same goes for Generic Object Instances where the "href"s of "button_groups" and "buttons" points to "generic_objects" collection instead of to "custom_button_sets" and "custom_buttons".
GET /api/generic_objects/:id?attributes=custom_action_buttons,custom_actions

Comment 4 CFME Bot 2017-12-18 22:39:59 UTC
New commit detected on ManageIQ/manageiq-api/master:
https://github.com/ManageIQ/manageiq-api/commit/76db03e6cfd896415fc1e531e4bbb96f3deef1a8

commit 76db03e6cfd896415fc1e531e4bbb96f3deef1a8
Author:     Tim Wade <hello@timjwade.com>
AuthorDate: Mon Dec 18 10:48:46 2017 -0800
Commit:     Tim Wade <hello@timjwade.com>
CommitDate: Mon Dec 18 14:12:26 2017 -0800

    Fix custom actions hrefs
    
    Because custom actions are represented as a plain hash in the model,
    we lose all context about the type of object we must add an href to in
    the normalization process. This process tries, in lieu of this
    context, to guess what the href path should look like, and is
    incorrectly linking these objects to the parent object's
    API (e.g. generic objects, services, etc..). Refactoring all of
    normalization to get the proper context will be necessary in order to
    fix this correctly. Instead, we intercept the result here, adding the
    correct hrefs, which will not be overwritten later.
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1518297

 app/controllers/api/base_controller/renderer.rb | 24 ++++++++++++
 spec/requests/generic_objects_spec.rb           | 50 +++++++++++++++++++++++++
 2 files changed, 74 insertions(+)


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