The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #13408

Hiera does not correctly handle (false) Booleans returned by the backends

Added by Lars Francke over 2 years ago. Updated over 1 year ago.

Status:Merged - Pending ReleaseStart date:03/26/2012
Priority:NormalDue date:
Assignee:Kelsey Hightower% Done:

0%

Category:hiera
Target version:1.0.0
Keywords:lowrider customer Affected Hiera Version:
Branch:https://github.com/puppetlabs/hiera/pull/68

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

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.


Related issues

Related to Hiera - Bug #12122: Hiera support for multiple backend Closed 01/24/2012

History

#1 Updated by Krzysztof Wilczynski over 2 years ago

Hi,

This might be somewhat related to #10590.

KW

#2 Updated by Carla Souza over 2 years ago

Hi,

I guess this was solved in this pull request by checking answer’s value is not nil instead of the line:

break if answer

C.

#3 Updated by Lars Francke over 2 years ago

Thanks Carla,

that indeed looks very much like that pull request might fix it. I looked through other open issues but didn’t look at pull requests… Great!

Unfortunately the patch doesn’t work properly either but I’ve commented on the pull request.

#4 Updated by Kelsey Hightower about 2 years ago

  • Status changed from Unreviewed to Accepted

#5 Updated by Kelsey Hightower about 2 years ago

  • Assignee set to Kelsey Hightower
  • Target version set to 1.0.0
  • Keywords set to lowrider

I believe this bug should be fixed as part of the RC process and should make it into Hiera 1.0.0

#6 Updated by Kelsey Hightower about 2 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”:

  • “false”
  • False
  • “n”
  • “N”

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 about 2 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:

https://github.com/puppetlabs/hiera/blob/master/spec/unit/backend_spec.rb#L222 https://github.com/puppetlabs/hiera/blob/master/spec/unit/backend_spec.rb#L176

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 about 2 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 about 2 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.

#11 Updated by Kelsey Hightower about 2 years ago

  • Status changed from Accepted to Merged - Pending Release
  • Branch set to https://github.com/puppetlabs/hiera/pull/68

#12 Updated by Charlie Sharpsteen over 1 year ago

  • Keywords changed from lowrider to lowrider customer

Also available in: Atom PDF