Jira (PUP-10413) Overriding a default argument with undef has no effect

8 views
Skip to first unread message

Felix (Jira)

unread,
Apr 6, 2020, 1:16:03 PM4/6/20
to puppe...@googlegroups.com
Felix created an issue
 
Puppet / Bug PUP-10413
Overriding a default argument with undef has no effect
Issue Type: Bug Bug
Affects Versions: PUP 5.5.10
Assignee: Unassigned
Components: Language
Created: 2020/04/06 10:15 AM
Priority: Normal Normal
Reporter: Felix

Puppet Version: 5.5.10
Puppet Server Version: N/A
OS Name/Version: Debian 10.3

$ cat testcase.pp
define resource($key = $name) {
  if($key == undef ){
    warning("Case 1")
  } else {
    warning("Case 2")
  }
}
resource{'blub':
  key => undef
}
$ puppet apply testcase.pp

Desired Behavior:

Warning: Scope(Resource[blub]): Case 1

Actual Behavior:

Warning: Scope(Resource[blub]): Case 2

The behavior seems to be kind-of intended:

From the docs:

The undef value is useful for testing whether a variable has been set. Also, you can use it to un-set resource attributes that have inherited values from a resource default, causing the attribute to be unmanaged.

So do I see this correctly that there is no way to pass "undef" to a resource which has a default assigned to the specific parameter?

Because it would seem natural to me, to have a resource, with an optional parameter, that has some default value, with the option to un-set this default value on a per-instance basis.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Rob Braden (Jira)

unread,
Apr 6, 2020, 1:47:02 PM4/6/20
to puppe...@googlegroups.com

Rob Braden (Jira)

unread,
Apr 6, 2020, 1:48:05 PM4/6/20
to puppe...@googlegroups.com

Henrik Lindberg (Jira)

unread,
Apr 6, 2020, 4:53:03 PM4/6/20
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PUP-10413
 
Re: Overriding a default argument with undef has no effect

You are right - this is by design; decisions made a long time ago in puppet. It is now expected behavior and changing it would break a lot of code.
For the Puppet 4 version I wanted to change this by allowing an override (such that an undef value could actually be set), but there was zero support for that idea.

Maggie Dreyer (Jira)

unread,
Oct 27, 2020, 2:49:03 PM10/27/20
to puppe...@googlegroups.com

We have no plans to change this given the impact.

Reply all
Reply to author
Forward
0 new messages