Puppet 3.7.1 parse problems with resource overrides.

728 views
Skip to first unread message

Tristan Smith

unread,
Sep 22, 2014, 2:48:20 PM9/22/14
to puppet...@googlegroups.com
So, new behavior that I'm not sure is intentional. File['blah'] works fine, File ['blah'] is now illegal - the additional whitespace causes the below stupendously readable error on puppet parser validate. 

Error: Could not parse for environment production: Expression is not valid as a resource, resource-default, or resource-override at (slice () 'file'):(slice () 'line'):(slice ([] (cat '' (str $myvar) '')) 'pos')

Is this a known bug I've failed to find on the ticket system, or intended behavior I've just missed in the notes? If not, I'll go chase it as a bug.

Tristan Smith

unread,
Sep 22, 2014, 3:10:36 PM9/22/14
to puppet...@googlegroups.com
One more, mostly just a 'wouldn't it be nice if this were clearly handled?' Having a comma at the end of an assignment like the below appears to cause confusion; mostly at this point my gripe is that the error line is reported as the enclosing class/define/whatever instead of at the line with the errant comma.

puppet parser validate --parser=future init.pp
Error: Could not parse for environment production: This Array Expression is not productive. A Host Class Definition can not end with a non productive construct at init.pp:1:1

class a {

  $foo = "bar",
  $banana = "apple"

Stefan Heijmans

unread,
Sep 23, 2014, 7:25:16 AM9/23/14
to puppet...@googlegroups.com

Hi,

Received the same kind of error with a different message, using Puppet 3.7.2 with future parser;
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at '[' at /etc/puppet/environments/tst/modules/managesoft/manifests/install.pp:41:23 on node <fqdn>

Had the following in my require statement;
require => [ File ['/var/tmp/mgsft_rollout_response'], File ['/var/tmp/ux.npl'] ]
fixed by removing spaces to;
require => [File['/var/tmp/mgsft_rollout_response'],File['/var/tmp/ux.npl']]

Stefan

Andy Parker

unread,
Sep 25, 2014, 3:03:53 PM9/25/14
to puppet...@googlegroups.com
Tristan, both of those are correct errors. The space between the "File" and the "['blah']" is an error because it makes it ambiguous about what was intended. This happens because puppet doesn't require any statement terminators (a semicolon in a lot of languages serves this purpose). So this is ambiguous about whether you meant to have an expression of the File type followed by creating an array or if you meant the File type parameterized with the title 'blah', both could be valid.

In both of the cases that you have here, that error message is pretty atrocious. The one with "slice" in it looks like it is dumping out some sort of AST structures for some reason in the location slot of the message. The error about the "non-productive construct" is a little trickier since the error is about the class, but is caused by the comma. I think you are right that it should show the location of the comma rather than the class.

Can you file both of these as bugs in the PUP project and include what version of puppet you are using?

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/27b39605-a929-4271-8a4b-b693337b7207%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Andrew Parker
Freenode: zaphod42
Twitter: @aparker42
Software Developer

Join us at PuppetConf 2014, September 20-24 in San Francisco - www.puppetconf.com 

Henrik Lindberg

unread,
Oct 1, 2014, 1:25:57 PM10/1/14
to puppet...@googlegroups.com
On 2014-23-09 13:25, Stefan Heijmans wrote:
> Hi,
>
> Received the same kind of error with a different message, using Puppet
> 3..7.2 with future parser;
> Error: Could not retrieve catalog from remote server: Error 400 on
> SERVER: Syntax error at '[' at
> /etc/puppet/environments/tst/modules/managesoft/manifests/install.pp:41:23
> on node <fqdn>
>
> Had the following in my require statement;
> require => [ File ['/var/tmp/mgsft_rollout_response'], File
> ['/var/tmp/ux.npl'] ]
> fixed by removing spaces to;
> require => [File['/var/tmp/mgsft_rollout_response'],File['/var/tmp/ux.npl']]
>
> Stefan

Posting this to clarify for those that google for problems...

This is a legit error message, you basically ended up with something
similar to this:

require => [File <anArray>, File <anArray>]

which is a syntax error since you cannot simply list entries in an array
without commas. You fixed it the correct way by removing the spaces
thereby making the [...] part into an access operation on the File type
instead of being a separate expression.

- henrik

--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Reply all
Reply to author
Forward
0 new messages