Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleDataProvider::validate_data_hash does not prune hash as advertised #9335

Closed
PaulGale opened this issue May 1, 2024 · 1 comment · Fixed by #9326
Closed

ModuleDataProvider::validate_data_hash does not prune hash as advertised #9335

PaulGale opened this issue May 1, 2024 · 1 comment · Fixed by #9326
Labels
bug Something isn't working

Comments

@PaulGale
Copy link

PaulGale commented May 1, 2024

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.

@PaulGale PaulGale added the bug Something isn't working label May 1, 2024
@mhashizume
Copy link
Contributor

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!

@mhashizume mhashizume linked a pull request May 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants