Bug 1302783

Summary: ERROR -- : Method STDERR: -:53: warning: wrong element type nil at 0 (expected array)
Product: Red Hat CloudForms Management Engine Reporter: Kevin Morey <kmorey>
Component: AutomateAssignee: Greg McCullough <gmccullo>
Status: CLOSED NOTABUG QA Contact: Dave Johnson <dajohnso>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 5.5.0CC: jhardy, mkanoor, obarenbo, tfitzger
Target Milestone: GA   
Target Release: 5.6.0   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-01-28 19:05:21 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:

Description Kevin Morey 2016-01-28 15:43:09 UTC
Description of problem:
When trying to collect $evm.root attributes into a Hash a STDERR message is thrown into the automation.log. I did not see this message in cfme 5.4 so something has changed to cause this to happen. If this is due to a deprecation error then i am open to a work-around. 


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

How reproducible:
100%

Steps to Reproduce:
1. Using simulation run the following:

dialog_add_disks_hash = Hash[$evm.root.attributes.sort.collect do |k, v| [k, v] if k.kind_of?(String) && k.starts_with?('dialog_add_disk') }]
puts "#{dialog_add_disks_hash}"

2.
3.

Actual results:
STDERR is thrown

Expected results:
No errors

Additional info:
[----] E, [2016-01-28T01:14:08.439391 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: wrong element type nil at 0 (expected array)
[----] E, [2016-01-28T01:14:08.439516 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: ignoring wrong elements is deprecated, remove them explicitly
[----] E, [2016-01-28T01:14:08.439594 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: this causes ArgumentError in the next release
[----] E, [2016-01-28T01:14:08.439692 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: wrong element type nil at 1 (expected array)
[----] E, [2016-01-28T01:14:08.439801 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: ignoring wrong elements is deprecated, remove them explicitly
[----] E, [2016-01-28T01:14:08.439880 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: this causes ArgumentError in the next release
[----] E, [2016-01-28T01:14:08.439983 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: wrong element type nil at 2 (expected array)
[----] E, [2016-01-28T01:14:08.440091 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: ignoring wrong elements is deprecated, remove them explicitly
[----] E, [2016-01-28T01:14:08.440318 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: this causes ArgumentError in the next release
[----] E, [2016-01-28T01:14:08.440401 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: wrong element type nil at 3 (expected array)
[----] E, [2016-01-28T01:14:08.440487 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: ignoring wrong elements is deprecated, remove them explicitly
[----] E, [2016-01-28T01:14:08.440567 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: this causes ArgumentError in the next release
[----] E, [2016-01-28T01:14:08.440641 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: wrong element type nil at 4 (expected array)
[----] E, [2016-01-28T01:14:08.440717 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: ignoring wrong elements is deprecated, remove them explicitly
[----] E, [2016-01-28T01:14:08.440816 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: this causes ArgumentError in the next release
[----] E, [2016-01-28T01:14:08.440892 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: wrong element type nil at 5 (expected array)
[----] E, [2016-01-28T01:14:08.441004 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: ignoring wrong elements is deprecated, remove them explicitly
[----] E, [2016-01-28T01:14:08.441096 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: this causes ArgumentError in the next release
[----] E, [2016-01-28T01:14:08.441177 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: wrong element type nil at 6 (expected array)
[----] E, [2016-01-28T01:14:08.441252 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: ignoring wrong elements is deprecated, remove them explicitly
[----] E, [2016-01-28T01:14:08.441441 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: this causes ArgumentError in the next release
[----] E, [2016-01-28T01:14:08.441518 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: wrong element type nil at 7 (expected array)
[----] E, [2016-01-28T01:14:08.441592 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: ignoring wrong elements is deprecated, remove them explicitly
[----] E, [2016-01-28T01:14:08.441679 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: this causes ArgumentError in the next release
[----] E, [2016-01-28T01:14:08.441773 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: wrong element type nil at 8 (expected array)
[----] E, [2016-01-28T01:14:08.441848 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: ignoring wrong elements is deprecated, remove them explicitly
[----] E, [2016-01-28T01:14:08.441945 #3049:a38ef3c] ERROR -- : Method STDERR: -:53: warning: this causes ArgumentError in the next release

Comment 2 Greg McCullough 2016-01-28 19:05:21 UTC
The change is that STDERR is now being logged.  The error is with the script logic which will produce the same errors if you running it in the rails console. (with minor tweaks to replace $evm with a usable hash for testing.)

Here is an example of how you can rewrite the method to avoid the errors:

dialog_add_disks_hash = $evm.root.attributes.sort.each_with_object({}) do |(k, v), h|
  h[k] = v if k.kind_of?(String) && k.starts_with?('dialog_add_disk')
do
puts "#{dialog_add_disks_hash.inspect}"


Also I do not think the sort is required and if so it could be done after on the shorter filtered list of items.  In place of the "kind_of?" check you can replaced it with a simple ".to_s" call as in this version:

dialog_add_disks_hash = $evm.root.attributes.each_with_object({}) do |(k, v), h|
  h[k] = v if k.to_s.starts_with?('dialog_add_disk')
end
puts "#{dialog_add_disks_hash.inspect}"