Issue #15448 has been updated by Jos Boumans.
Ashley Penney wrote:
> On 3.x this now errors as you'd expect:
>
> Error: Failed to parse inline template: undefined method `length' for
> nil:NilClass at /home/apenney/tests/puppet/var.pp:2 on node arya.untaken.net
> Error: Failed to parse inline template: undefined method `length' for
> nil:NilClass at /home/apenney/tests/puppet/var.pp:2 on node arya.untaken.net
Ashley, thanks, that fixes the $y case.
But the actual problem for me is the $x case:
I don't expect it to error, I expect it to return something that is not True -
the "if $x" check should fail, not succeed.
----------------------------------------
Bug #15448: scope.lookupvar('any variable') is always TRUE.
https://projects.puppetlabs.com/issues/15448#change-67720
Author: Jos Boumans
Status: Unreviewed
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.