Bug 1651099

Summary: Custom button attribute override message
Product: Red Hat CloudForms Management Engine Reporter: Cyril Coupel <ccoupel>
Component: AutomateAssignee: drew uhlmann <duhlmann>
Status: CLOSED CURRENTRELEASE QA Contact: Nikhil Dhandre <ndhandre>
Severity: high Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: high    
Version: 5.10.0CC: akarol, bmidwood, dhalasz, hkataria, lavenel, mfeifer, mkanoor, mpovolny, obarenbo, simaishi, tfitzger, wfitzger
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.11.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.11.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1672693 (view as bug list) Environment:
Last Closed: 2019-12-13 15:16:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1672693    
Attachments:
Description Flags
Before Attachment
none
After Attachment none

Description Cyril Coupel 2018-11-19 08:23:48 UTC
Description of problem:
when creating a custom button to request call_instance_with_message, the message attribut override the message of the request

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

How reproducible:
every time

Steps to Reproduce:
1. create a custom button to request the call_instance_with_message
2. set the message to create
3. set the attributes instance, class, namespace to "whatever"
4. set the attribute message to "my_message"
5. save it

Actual results:
the message of the request is set to the value of the message attribute "my_message" instead of "create"

Expected results:
the message is set to "create" and the message attribute is set to "my_message"

Additional info:

Comment 2 William Fitzgerald 2018-11-27 20:55:49 UTC
The UI is changing the value of message in Object Details (see Before Attachment) to the value of message in Attribute/Value Pairs (see After Attachment).

Comment 3 William Fitzgerald 2018-11-27 20:57:12 UTC
Created attachment 1509206 [details]
Before Attachment

Comment 4 William Fitzgerald 2018-11-27 20:57:59 UTC
Created attachment 1509207 [details]
After Attachment

Comment 5 William Fitzgerald 2018-11-27 21:07:44 UTC
I recreated this on appliance 10.8.196.247.  I created a button called 'call instance with message' on VM and Instance.

Comment 6 Dávid Halász 2018-11-28 11:16:18 UTC
Hi Billy,

I backtraced this to the `MiqAeEngine.create_automation_object` method in the automation engine gem. I added the breakpoint after the [1] call of this method and found out that the generated URI doesn't contain the "create" as the message, but it uses the message from the attribute/value pairs, i.e. "billy%20messages". Then to set the message for the DB record, this URI is being parsed [2]. 

```
@edit[:new][:object_message]
=> "create"

@edit[:uri]
=> "/SYSTEM/PROCESS/Request?MiqServer%3A%3Amiq_server=16&User%3A%3Auser=1&class=Request&instance=TestNotification&message=billy%20messages&namespace=%2FSystem&object_name=Request#billy%20messages"
```

My question: is this a bug or a feature in the `create_automation_object` method, i.e. does it behave wrong or should I work this around?

[1] https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/application_controller/buttons.rb#L532

[2] https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/application_controller/buttons.rb#L865

Comment 7 William Fitzgerald 2018-11-29 19:42:17 UTC
Hi David,

#billy%20messages" - This needs to be create, this is the object message
&message=billy%20messages - This is correct, This is the attribute message

The attribute message is overriding the object message and it should not.

Thanks

Billy

Comment 8 William Fitzgerald 2018-11-29 19:52:46 UTC
For Comment 7

Comment 11 drew uhlmann 2019-01-14 20:58:42 UTC
Sorry Dávid, totally giving this back to you since it looks to be wrong before it ever hits Automate.