Issue #16178 has been updated by Josh Cooper.

Status changed from Accepted to In Topic Branch Pending Review
Target version set to 3.0.x
Affected Puppet version set to 3.0.0
Branch set to https://github.com/puppetlabs/puppet/pull/1282


----------------------------------------
Bug #16178: Boolean false in a variable causes the puppet backend lookup to fail
https://projects.puppetlabs.com/issues/16178#change-76944

Author: Ellison Marks
Status: In Topic Branch Pending Review
Priority: Normal
Assignee: 
Category: 
Target version: 3.0.x
Affected Puppet version: 3.0.0
Keywords: boolean false lookup
Branch: https://github.com/puppetlabs/puppet/pull/1282


possibly related to #13408, but for the puppet backend instead.

If you set hiera to go get a variable, and that variable contains boolean 
false, catalog compilation will fail. Boolean true works fine though.

Relevant code from hiera/backend/puppet_backend.rb:

<pre>
          unless loaded_classes.include?(klass)
            begin
              if scope.respond_to?(:function_include)
                scope.function_include(klass)
              else
                scope.real.function_include(klass)
              end

              temp_answer = scope[varname]
              Hiera.debug("Found data in class #{klass}")
            rescue
            end
          else
            temp_answer = scope[varname]
          end

          next if temp_answer == :undefined

          if temp_answer
            # For array resolution we just append to the array whatever we
            # find, we then go onto the next file and keep adding to the array.
            #
            # For priority searches we break after the first found data item.
            case resolution_type
</pre>

The part that's failing is "if temp_answer". At my best guess, that check is 
there to prevent returning empty answers, such as "", [] or {}. However, it's 
also preventing returning false correctly. Additionally, in my opinion, empty 
strings or arrays or hashes might at times be a valid answer.

Proposed solution would be to get rid of that if block. That would allow 
boolean false to correctly make it through, as well as allowing empty strings, 
arrays and hashes as answers. This would also, it looks like, bring this 
backend's behavior in line with that of the yaml backend.


-- 
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