Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

pdk validate --auto-correct fails trying to fix indent #107

Open
Ah-Puch opened this issue Mar 11, 2023 · 1 comment
Open

pdk validate --auto-correct fails trying to fix indent #107

Ah-Puch opened this issue Mar 11, 2023 · 1 comment
Labels
bug Something isn't working community

Comments

@Ah-Puch
Copy link

Ah-Puch commented Mar 11, 2023

Describe the Bug

Trying to run " pdk validate --auto-correct --parallel" on the attached code will cause an error.

Expected Behavior

Should succeed and output corrected code with indent

Steps to Reproduce

Create the class (files needed attached at the end)
pdk validate --auto-correct

Environment

  • PDK Version 2.6.1
  • puppet lint 2.5.2
  • Platform Ubuntu 20.04

demo@demo-u20-lts:~/$ dpkg --list | egrep pdk
ii pdk 2.6.1.0-1focal amd64 Puppet Development Kit

Additional Context

demo@demo-u20-lts:~/puppet/demo_array_of_hashes$ cat data/common.yaml

demo_array_of_hashes::users:

  • id: 'one'
    quota: '10'
  • id: 'two'
    quota: '20'

demo@demo-u20-lts:~/puppet/demo_array_of_hashes$ more manifests/init.pp
class demo_array_of_hashes () {

$users = lookup('demo_array_of_hashes::users')
notice(inline_template("
<% @users.each do |user| -%>
id=<%= user['id'] %>
quota=<%= user['quota'] %>
<% end -%>
"))

}

demo@demo-u20-lts:~/puppet/demo_array_of_hashes$ pdk validate --auto-correct
pdk (INFO): Using Ruby 2.7.7
pdk (INFO): Using Puppet 7.22.0
pdk (INFO): Running all available validators...
pdk (INFO): Validator 'puppet-epp' skipped for '/home/demo/puppet/demo_array_of_hashes'. No files matching '["/*.epp"]' found to validate.
pdk (INFO): Validator 'task-name' skipped for '/home/demo/puppet/demo_array_of_hashes'. No files matching '["tasks/
/"]' found to validate.
pdk (INFO): Validator 'task-metadata-lint' skipped for '/home/demo/puppet/demo_array_of_hashes'. No files matching '["tasks/
.json"]' found to validate.
┌ [✔] Running metadata validators ...
├── [✔] Checking metadata syntax (metadata.json tasks/.json).
└── [✔] Checking module metadata style (metadata.json).
┌ [✖] Running puppet validators ...
├── [✔] Checking Puppet manifest syntax (**/
.pp).
└── [✖] Checking Puppet manifest style (**/*.pp).
[
Whoops! It looks like puppet-lint has encountered an error that it doesn't
know how to handle. Please open an issue at https://github.com/rodjek/puppet-lint
and paste the following output into the issue description.

puppet-lint version: 2.5.2
ruby version: 2.7.7-p221
platform: x86_64-linux
file path: manifests/init.pp
file contents:

class demo_array_of_hashes () {

  $users = lookup('demo_array_of_hashes::users')
  notice(inline_template("
  <% @users.each do |user| -%>
  id=<%= user['id'] %>
  quota=<%= user['quota'] %>
  <% end -%>
  "))

}

error:

NoMethodError: undefined method `type' for nil:NilClass
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-strict_indent-check-2.1.0/lib/puppet-lint/plugins/check_strict_indent.rb:163:in `fix'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-2.5.2/lib/puppet-lint/checkplugin.rb:42:in `block in fix_problems'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-2.5.2/lib/puppet-lint/checkplugin.rb:38:in `each'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-2.5.2/lib/puppet-lint/checkplugin.rb:38:in `fix_problems'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-2.5.2/lib/puppet-lint/checks.rb:67:in `block in run'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-2.5.2/lib/puppet-lint/checks.rb:65:in `each'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-2.5.2/lib/puppet-lint/checks.rb:65:in `run'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-2.5.2/lib/puppet-lint.rb:205:in `run'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-2.5.2/lib/puppet-lint/bin.rb:66:in `block in run'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-2.5.2/lib/puppet-lint/bin.rb:62:in `each'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-2.5.2/lib/puppet-lint/bin.rb:62:in `run'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppet-lint-2.5.2/bin/puppet-lint:7:in `<top (required)>'
/home/tj/puppet/demo_array_of_hashes/bin/puppet-lint:29:in `load'
/home/tj/puppet/demo_array_of_hashes/bin/puppet-lint:29:in `<main>'

┌ [✔] Running ruby validators ...
└── [✔] Checking Ruby code style (/.rb).
┌ [✔] Running tasks validators ...
├── [✔] Checking task names (tasks//).
└── [✔] Checking task metadata style (tasks/
.json).
┌ [✔] Running yaml validators ...
└── [✔] Checking YAML syntax (
/.yaml **/.yml).

@Ah-Puch Ah-Puch added the bug Something isn't working label Mar 11, 2023
@chelnak
Copy link

chelnak commented Mar 11, 2023

Thanks for this. We will take a look and get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community
Projects
None yet
Development

No branches or pull requests

3 participants