Issue #6956 has been reported by Konrad Scherer.

----------------------------------------
Bug #6956: has_fact method assumes fact is present on node
https://projects.puppetlabs.com/issues/6956

Author: Konrad Scherer
Status: Unreviewed
Priority: Low
Assignee: R.I. Pienaar
Category: Core
Target version: 
Keywords: 
Branch: 
Affected mCollective version: 1.1.2


If has_fact is called with a fact not available on the node, the 
Facts.get_fact(fact).clone method fails. The get_fact method returns nil if the 
fact is not found. I am using the yaml_facts.rb plugin with mcollective 1.1.2. 
I checked 1.1.3 and it seems to suffer from the same problem.

Here is a simple patch.

diff --git a/lib/mcollective/util.rb b/lib/mcollective/util.rb
index c0abbcf..b0aa914 100644
--- a/lib/mcollective/util.rb
+++ b/lib/mcollective/util.rb
@@ -59,6 +59,7 @@ module MCollective
             Log.debug("Comparing #{fact} #{operator} #{value}")
             Log.debug("where :fact = '#{fact}', :operator = '#{operator}', 
:value = '#{value}'")
 
+            return false if Facts.has_fact?( fact )
             fact = Facts.get_fact(fact).clone
 
             if operator == '=~'



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to