The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com
https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:
Hiera does not correctly handle (false) Booleans returned by the backends
|Status:||Merged - Pending Release||Start date:||03/26/2012|
|Assignee:||Kelsey Hightower||% Done:|
|Keywords:||lowrider customer||Affected Hiera Version:|
Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com
This is similar to but not the same as issue #10590.
When any backend returns a false boolean (YAML for example) the lookup fails:
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find data item foo in any Hiera data file and no default supplied at ... on node ...
This is because in the backend.rb lookup method there is this code:
break if answer
which doesn’t work if answer is “false”. I don’t know the proper way of fixing this. In YAML one can just quote the values or in parse_answer return data.to_s instead of just data.
This is on hiera-0.3.0.
#6 Updated by Kelsey Hightower almost 4 years ago
This all boils down to Hiera not supporting booleans as valid answers. Since Hiera is checking the the bankend’s response for a value that is “True” based on Ruby’s boolean logic, “False” values will never be returned.
When using the YAML backed end the following values are “False”:
That’s based on the YAML Spec.
I’m a bit worried that people maybe relying on Hiera’s current behavior and changing how this works can cause a negative impact to our users. The next release of Hiera is aimed at stabilizing the current behavior. However, I’m willing to make a patch for this and get feedback from the community. If the change is desired I’ll issue a pull request against the RC branch.
#7 Updated by Kelsey Hightower almost 4 years ago
Ok, so I’ve verified that Hiera does allow backends to return Boolean values. There are even a bunch of tests already in place for this:
Now that I’ve confirmed that Hiera seems to be working. I will take a look at the paser function.
#8 Updated by Kelsey Hightower almost 4 years ago
So I’ve taken a look at the Puppet parser function and it seems to allow boolean values. I’m testing this on the master branch of hiera-puppet. To help me reproduce this issue can you provide the version of puppet-hiera, an example manifests, and an example of the YAML data you’re using?
#9 Updated by Lars Francke almost 4 years ago
As mentioned above all of this was on Hiera 0.3.0 and I even pointed to the code where the failure happens. Any YAML file with a false boolean value “foo: false” failed. I haven’t tried with the latest 1.0 RC but looking at the lookup.rb code the same bug still seems to be there. Please also look at Carla’s fix above.
If I understand the tests properly they test something else. The second one at least tests if the Backends properly return “false” which they do! The problem is in hiera’s lookup method.
Please let me know if I should go into more detail.
#10 Updated by Patrick Carlisle almost 4 years ago
I think the change in https://github.com/puppetlabs/hiera/commit/f4411514847a13621c142b902cea2d8ed7197391 will fix this.