Jira (PUP-10890) empty lookup_options

0 views
Skip to first unread message

Chris Denneen (Jira)

unread,
Feb 5, 2021, 3:58:02 PM2/5/21
to puppe...@googlegroups.com
Chris Denneen created an issue
 
Puppet / Bug PUP-10890
empty lookup_options
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/02/05 12:57 PM
Priority: Normal Normal
Reporter: Chris Denneen

Doing a test on a module with hiera that has an empty `lookup_options:` will result in errors during unit tests like 

 

  1. — Caused by: —
  2. NoMethodError:
  3. undefined method `each_pair' for nil:NilClass
  4. /opt/puppetlabs/pdk/private/puppet/ruby/2.4.0/gems/puppet-5.5.21/lib/puppet/pops/lookup/lookup_adapter.rb:292:in `validate_lookup_options'
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Feb 5, 2021, 5:15:05 PM2/5/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10890
 
Re: empty lookup_options

That's odd. That line is https://github.com/puppetlabs/puppet/blob/901a6296a8f0a19849ef35575a78b7ad3dd377f4/lib/puppet/pops/lookup/lookup_adapter.rb#L292, but we check for a nil options above on line 288 and those lines haven't changed for several years. Going to need more information on how to reproduce this.

Henrik Lindberg (Jira)

unread,
Feb 6, 2021, 7:03:03 AM2/6/21
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PUP-10890
 
Re: empty lookup_options

line 288 is weird with two trailing unless - I think it errors as it should if value is neither nil nor a hash. Then it returns options as is if modulename is not given. Then it will fail if options are nil on line 292. The correct thing is probably to change line 293 to read:

return options if module_name.nil? || options.nil?

Chris Denneen (Jira)

unread,
Feb 6, 2021, 7:36:05 AM2/6/21
to puppe...@googlegroups.com
Chris Denneen commented on Bug PUP-10890
 
Re: empty lookup_options

@Josh Cooper the issue is seen when the module has empty hash (I had the old keys actually commented out) and you run a “pdk test unit”. Should be pretty straight forward to reproduce?

Beth Glenfield (Jira)

unread,
Jun 3, 2021, 4:43:01 AM6/3/21
to puppe...@googlegroups.com
Beth Glenfield updated an issue
Change By: Beth Glenfield
Labels: community
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Aug 18, 2021, 12:44:02 PM8/18/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10890
 
Re: empty lookup_options

ah yeah I can reproduce, I created a simple module mytest containing:

./manifests/init.pp

class mytest {
  notice(lookup('key'))
}

./data/common.yaml

---
lookup_options:
mytest::key: from module

./hiera.yaml

[root@sized-ballerina mytest]# cat  hiera.yaml 
---
version: 5
 
hierarchy:
  - name: 'common'
    path: 'common.yaml'

# puppet --version
7.10.0
# puppet lookup mytest::key  --modulepath /root/modules --trace
Error: Could not run: undefined method `each_pair' for nil:NilClass
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/lookup/lookup_adapter.rb:299:in `validate_lookup_options'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/lookup/lookup_adapter.rb:352:in `block (3 levels) in retrieve_lookup_options'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/lookup/lookup_adapter.rb:351:in `catch'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/lookup/lookup_adapter.rb:351:in `block (2 levels) in retrieve_lookup_options'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/lookup/invocation.rb:136:in `with'
...

Josh Cooper (Jira)

unread,
Aug 18, 2021, 3:56:02 PM8/18/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: PUP 6.25.0
Fix Version/s: PUP 7.11.0

Josh Cooper (Jira)

unread,
Aug 18, 2021, 3:56:03 PM8/18/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Coremunity
Reply all
Reply to author
Forward
0 new messages