-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent attribute names inside Automate Engine #13440
Conversation
@tinaafitz @gmcculloug |
https://bugzilla.redhat.com/show_bug.cgi?id=1408482 Inside the Automate Engine we convert the attribute name for simple data types to lowercase, but for vmdb or Array types we dont convert the attribute name to lowercase. This PR converts all attribute names to lowercase. This is inconsistent. e.g. VM::VM=100&Name=fred would yield 2 attribute names VM and name. The "name" got converted to lowercase but VM didn't. When the methods access these variables using $evm.root we internally convert it to lowercase at access time $evm.root['VM'] gets converted to $evm.root['vm'] $evm.root['vm'] gets converted to $evm.root['vm'] $evm.root['Name'] gets converted to $evm.root['Name'] If the caller passed in VM::VM=100&Name=fred $evm.root['VM'] fails because the method layer converts it to lowercase and internally it has preserved its original case This is not that prevalent since most of the attribute names that embed the class type are generated internally and they always lowercase the name. We have seen this manifest itself when using Tag controls using dialogs and the user names the tag with mixed case e.g. TagControl would be stored in the engine as dialog_TagControl but when the methods try to access $evm.root['dialog_TagControl'] the method layer would lowercase it and not find the attribute.
637a044
to
e6bff3a
Compare
expect(result["vms"].length).to eq(1) | ||
expect(result["name"]).to eq("fred") | ||
expect(result["Name"]).to be_nil | ||
expect(result["VMs"]).to be_nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, but can you move this check for VMs
next to the vms
tests so they are grouped together. Makes it clearer what you are testing.
One minor comment on the spec both otherwise this looks good. |
@@ -273,7 +273,7 @@ def process_args_attribute(args, args_key) | |||
key, klass = get_key_name_and_klass_from_key(args_key) | |||
value = args.delete(args_key) | |||
args["#{key}_id"] = value unless @attributes.key?(key) | |||
args[key] = MiqAeObject.convert_value_based_on_datatype(value, klass) | |||
args[key.downcase] = MiqAeObject.convert_value_based_on_datatype(value, klass) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkanoor The key is already lower case here.
Checked commits mkanoor/manageiq@c3379ae~...18c82f1 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 |
Backported to Euwe via #13545 |
Inside the Automate Engine we convert the attribute name for
simple data types to lowercase, but for Array types we dont
convert the attribute name to lowercase.
This PR converts all attribute names to lowercase.
This is inconsistent.
e.g. Array::VM=VM::100&Name=fred
would yield 2 attribute names VM and name. The "name" got converted to
lowercase but VM didn't.
When the methods access these variables using $evm.root we internally
convert it to lowercase at access time
$evm.root['VM'] gets converted to $evm.root['vm']
$evm.root['vm'] gets converted to $evm.root['vm']
$evm.root['Name'] gets converted to $evm.root['name']
If the caller passed in Array::VM=VM::100&Name=fred
$evm.root['VM'] fails because the method layer converts it to lowercase
and internally it has preserved its original case
This is not that prevalent since most of the attribute names that embed
the class type are generated internally and they always lowercase the
name. We have seen this manifest itself when using Tag controls using
dialogs and the user names the tag with mixed case e.g.
TagControl would be stored in the engine as dialog_TagControl but when
the methods try to access $evm.root['dialog_TagControl'] the method
layer would lowercase it and not find the attribute.
Links
Steps for Testing/QA
Screen Shot attached