puppetlabs / puppet

Server automation framework and application

Home Page:https://puppet.com/open-source/#osp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ModuleDataProvider::validate_data_hash does not prune hash as advertised

PaulGale opened this issue · comments

The function ModuleDataProvider::validate_data_hash is supposed to prune all hiera keys that are not prefixed with the configured module_name. It does not.

Instead it returns the hash that it was called with unchanged. All pruning is done on a cloned version of the supplied hash that’s discarded and not returned to the caller.

def validate_data_hash(data_hash)

Desired Behavior:

  • It should prune all Hiera keys that are not prefixed with the configured module name.
  • It should include the name of any offending key(s) in the warning message that it prints. The warning message as currently implemented doesn't provide the developer with any meaningful actionable information.
    Puppet.warning("Module '#{module_name}': #{msg}")
    should be modified to be something like: Puppet.warning("Module '#{module_name}': #{msg}, key=#{k}") to help identify the offending key(s).

Actual Behavior:

  • Hiera keys not prefixed with the module name are not pruned from the supplied hash.
  • No warning advising on the offending key(s) is printed.

Fix:

Delete this line and the pruned hash is returned:
https://github.com/puppetlabs/puppet/blob/main/lib/puppet/pops/lookup/module_data_provider.rb#L57

Environment

This issue was detected when using Puppet Bolt. The underlying version of Puppet, used by Bolt, was 7.20.0. Note that this is a bug with Puppet, not with Bolt.

When this issue is fixed it might well result in other bugs in how Bolt handles such Hiera key and their lookups as Bolt doesn't prefix key names with the module_name as the module_name IS the Bolt project name itself.

Hi Paul,

Thanks for reporting this. We migrated your original Jira ticket over to GitHub Issues in #9204 and have a PR open to address this at #9326

I'm going to close this Issue as a duplicate.

Thanks!