Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

class with "apply" attribute causes parser error #251

Closed
kreeuwijk opened this issue Aug 11, 2020 · 6 comments · Fixed by #266
Closed

class with "apply" attribute causes parser error #251

kreeuwijk opened this issue Aug 11, 2020 · 6 comments · Fixed by #266
Labels

Comments

@kreeuwijk
Copy link

Describe the Bug

On a manifest that contains the following code:

reboot { 'Patching as Code - Patch Reboot':
  apply    => 'immediately',
  schedule => 'Patching as Code - Patch Window'
}

The puppet strings parser errors out with

[error]: Failed to parse manifests/init.pp: Syntax error at 'apply' (line: 173, column: 3)

If the specific line with apply => gets commented out, the parser succeeds.

Expected Behavior

The strings parser should not handle occurrences of the term apply as a special case, if they are attributes of classes.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create a valid puppet manifest
  2. Add a resource that contains an attribute named apply
  3. Run puppet parser validate to confirm the manifest is valid
  4. Run puppet strings generate
  5. Notice the parser chokes on the apply attribute.

Environment

  • PE 2019.8.0
  • Client: MacOS, Puppet Agent 6.0.2, puppet-strings 2.4.0, yard 0.9.24
@kreeuwijk kreeuwijk added the bug label Aug 11, 2020
@binford2k
Copy link
Contributor

If you set tasks=true before invoking puppet parser validate, you'll get the same error.

@trevor-vaughan
Copy link
Contributor

👍 I just hit this as well using augeasproviders_sysctl which has an apply parameter.

@s-johansson
Copy link

Most of icinga2 resources are using the apply attribute, they can't be rendered by puppet strings currently.

scoiatael pushed a commit to scoiatael/puppet-strings that referenced this issue Dec 17, 2020
@scoiatael
Copy link

I've modified unit tests to catch this issue with scoiatael@56f826b but looks like the stacktrace points to puppet parser internals:

puppet-strings/.bundle/gems/ruby/2.6.0/gems/puppet-7.1.0/lib/puppet/pops/parser/parser_support.rb:133:in `on_error'
puppet-strings/.bundle/gems/ruby/2.6.0/gems/puppet-7.1.0/lib/puppet/pops/parser/lexer2.rb:711:in `scan'
Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/racc/parser.rb:320:in `_racc_yyparse_c'
Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/racc/parser.rb:320:in `yyparse'
puppet-strings/.bundle/gems/ruby/2.6.0/gems/puppet-7.1.0/lib/puppet/pops/parser/parser_support.rb:241:in `_parse'
puppet-strings/.bundle/gems/ruby/2.6.0/gems/puppet-7.1.0/lib/puppet/pops/parser/parser_support.rb:140:in `parse_string'
puppet-strings/lib/puppet-strings/yard/parsers/puppet/parser.rb:30:in `parse'
puppet-strings/.bundle/gems/ruby/2.6.0/gems/yard-0.9.25/lib/yard/parser/source_parser.rb:442:in `parse'
puppet-strings/.bundle/gems/ruby/2.6.0/gems/yard-0.9.25/lib/yard/parser/source_parser.rb:124:in `parse_string'
puppet-strings/spec/unit/puppet-strings/markdown_spec.rb:25:in `parse_shared_content'
puppet-strings/spec/unit/puppet-strings/markdown_spec.rb:59:in `block (3 levels) in <top (required)>'

so I'm not sure if this issue shouldn't be opened against puppet itself.

binford2k added a commit to binford2k/puppet-strings that referenced this issue Dec 17, 2020
tested pathname is not the same pattern, so the regex fails. Do you have
suggestions @scotje?

Fixes puppetlabs#251
binford2k added a commit to binford2k/puppet-strings that referenced this issue Dec 17, 2020
The tests fail because the tested pathname is not the same pattern, so
the regex fails. Do you have suggestions @scotje?

Fixes puppetlabs#251
@trevor-vaughan
Copy link
Contributor

The code certainly runs fine, if that matters.

@joshcooper
Copy link
Contributor

Also reported in https://tickets.puppetlabs.com/browse/PUP-10824

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants