Issue #15448 has been updated by Jos Boumans.

I'm glad the inconsistent behaviour is being fixed, but it leaves us with a 
very practical problem:

In 2.6, the .length() check is needed to ensure proper behaviour.
In 2.7, the .length() check will cause a fatal exception.

What is the code our ERB should use to work in both 2.6 and 2.7, so we can 
upgrade cleanly, without having to do a code freeze, comb through all the code, 
etc?
----------------------------------------
Bug #15448: scope.lookupvar('any variable') is always TRUE.
https://projects.puppetlabs.com/issues/15448#change-72576

Author: Jos Boumans
Status: Duplicate
Priority: Normal
Assignee: 
Category: 
Target version: 
Affected Puppet version: 2.6.16
Keywords: 
Branch: 


Even when such a variable doesn't exist or hasn't been defined. 

Consider the following script:

<pre>
$ cat z.pp
$x = inline_template( "<% if scope.lookupvar('foo') %>foo <%= 
scope.lookupvar('foo') -%><% end %>" )
$y = inline_template( "<% if scope.lookupvar('foo').length > 0 %>foo <%= 
scope.lookupvar('foo') -%><% end %>" )
notice( "x: $x" )
notice( "y: $y" )
</pre>

I'd expect both notices to NOT print out "foo". However, the "x:" line does:

<pre>
$ sudo puppet z.pp
notice: Scope(Class[main]): x: foo 
notice: Scope(Class[main]): y: 
</pre>

If the scope.lookupvar is omitted, and just <% if foo %> is used, this throws a 
puppet error,
which is not desired, but much more along the lines of expectation.

<pre>
Failed to parse inline template: Could not find value for 'foo' at z.pp:1 on 
node ...
</pre> 


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to