[PUP-6613] regression: explicit undef cannot be used in create_resources Created: 2016/08/15  Updated: 2016/08/24  Resolved: 2016/08/22

Status: Closed
Project: Puppet
Component/s: None
Affects Version/s: None
Fix Version/s: PUP 4.6.1

Type: Bug Priority: Normal
Reporter: Henrik Lindberg Assignee: Phong Ly
Resolution: Fixed Votes: 0
Labels: regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MODULES-3715 ensure_resource fails with undef para... Needs Information
relates to MODULES-3442 postgresql::server::extension tests f... Ready for Merge
relates to PUP-6385 No title provided and "" is not a val... Closed
Template:
Story Points: 2
Sprint: Language 2016-08-24
Release Notes: Bug Fix
Release Notes Summary: A regression made it impossible to give an attribute as {{undef}} when there is no default value expression for a resource parameter and using {{create_resources}} to create the resource. There was no regression when doing the same from a manifest directly.

 Description   

The following code works when evaluated from a manifest:

puppet apply -e 'define foo($foo) {} foo { "FOO": foo => undef }'

But not when done using create_resources.

The rule puppet should use is: if undef is given then use the default value if one exists, otherwise set an explicit undef. Now the create_resources function simply filters out all undef values. (If simply kept, there are other problems since relationships cannot handle undef entries.



 Comments   
Comment by Henrik Lindberg [ 2016/08/17 ]

merged to stable at: 9041770

Comment by Phong Ly [ 2016/08/22 ]

Bug fixed in 4.6.1, tested with puppet-agent at SHA=ad760e51

explicit 'underf' can be used in create_resources

[root@l2svnpnftsuhtuo ~]# puppet apply -e "notify { test: } create_resources('notify', {'foo'=>{'require'=>[undef]}})"
Notice: Compiled catalog for l2svnpnftsuhtuo.delivery.puppetlabs.net in environment production in 0.08 seconds
Notice: test
Notice: /Stage[main]/Main/Notify[test]/message: defined 'message' as 'test'
Notice: foo
Notice: /Stage[main]/Main/Notify[foo]/message: defined 'message' as 'foo'
Notice: Applied catalog in 0.07 seconds
[root@l2svnpnftsuhtuo ~]#
[root@l2svnpnftsuhtuo ~]#
[root@l2svnpnftsuhtuo ~]# cat test.pp
define foocreateresource($one = 'xx') {
   notify { $name: message => "aaa${one}bbb" }
 }
 
create_resources('foocreateresource', {'blah'=>{ one => undef}})
[root@l2svnpnftsuhtuo ~]# puppet apply test.pp
Notice: Compiled catalog for l2svnpnftsuhtuo.delivery.puppetlabs.net in environment production in 0.08 seconds
Notice: aaaxxbbb
Notice: /Stage[main]/Main/Foocreateresource[blah]/Notify[blah]/message: defined 'message' as 'aaaxxbbb'
Notice: Applied catalog in 0.06 seconds
[root@l2svnpnftsuhtuo ~]#

Generated at Sat Dec 07 20:52:59 PST 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.