The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #14677

Puppet 3.0.x variable assigned to undef returns :undef in template

Added by Jeff McCune over 2 years ago. Updated almost 2 years ago.

Status:DuplicateStart date:05/23/2012
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:parser
Target version:-
Affected Puppet version: Branch:
Keywords:scope lookupvar template undef undefined nil

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

Overview

We’ve made good progress returning nil values in ERB templates in 3.0.x but we’re not out of the wood yet.

A fairly common pattern is to assign undef to a variable in the Puppet DSL, meaning “Treat this variable as undefined.”

The expected behavior is that the variable behaves as if it were not defined. The following manifest should illustrate the problem. The expected behavior is that we receive nil.

$undefined = undef
$foo = inline_template("<% require 'pry'; binding.pry; vapid_var; %>")
[7] pry(#)> scope.lookupvar('undefined_no_really')
=> nil
[8] pry(#)> scope.lookupvar('undefined')
=> :undef

Related issues

Related to Puppet - Bug #5820: Undefined variables throw poor error Duplicate 01/10/2011
Duplicated by Puppet - Bug #15329: Puppet lacks a proper "undefined" value Accepted 07/02/2012

History

#1 Updated by Kelsey Hightower over 2 years ago

  • Status changed from Unreviewed to Accepted
  • Affected Puppet version deleted (3.0.0rc2)

#2 Updated by Jeff McCune about 2 years ago

  • Status changed from Accepted to Duplicate

Action Required

We have gone back and forth on this a lot. At the very best we’re wildly inconsistent in 3.x and all of our values for undef internally evaluate to truth and internally have non-empty to_s implementations.

Based on the huge number of undef related tickets in the issue tracker, I’m making a stand and saying #15329 is the real root cause of all of these issue. If you are a watcher on this ticket, please transfer your most pressing concerns to #15329.

Here is the list of related “undef” issues that I’ve found so far: #4692 #5820 #6621 #6745 #8778 #8783 #13210 #14654 #14677 #14666

I am going to close this ticket as a duplicate of #15329. Again, please transfer your most pressing concerns to #15329 in an effort to consolidate all of the issues related to undef variables in the Puppet DSL.

Thanks, -Jeff

#3 Updated by Andrew Parker almost 2 years ago

  • Target version deleted (3.x)

Also available in: Atom PDF