adrianlzt/hiera-postgres-backend — pull request #3 by cestith (2014-03-17 16:27:58+00:00)
Title: Return nil for failed lookups (empty hashes and empty arrays).

According to http://docs.puppetlabs.com/hiera/1/puppet.html#automatic-parameter-lookup all Puppet classes declared in a resource-like manner will search for defaults in Hiera unless those defaults are specifically overridden in the class declaration.

This means that unless there is a hierarchy for such a module with a suitable query that an empty array would have been returned. The PuppetLabs modules such as puppetlabs-puppetdb do not deal well with an empty array and expect nil to be returned in the case of no data found in the backend.

This patch checks for empty arrays and empty hashes, setting the return value to nil if it finds those. This lets modules which expect to find valid data if anything other than nil is returned to continue to work with their defaults.