Uploaded image for project: 'Puppet Development Kit'
  1. Puppet Development Kit
  2. PDK-1046

PDK validate fails with nil:NilClass on puppet parser validate errors

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • PDK 1.6.0
    • PDK 1.6.1
    • None
    • Windows with PDK 1.6.0

    • Puppet Developer Experience
    • Customer Feedback
    • Bug Fix
    • Improved handling of unexpected errors when parsing the output of `puppet parser validate` as part of `pdk validate`.
    • Needs Assessment

    Description

      When running PDK validate the command fails with the following error. 

       

       
      [\] Checking Puppet manifest syntax (**/**.pp).C:/PWKit/PuppetDevKit/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.6.0/lib/pdk/validate/puppet/puppet_syntax.rb:89:in `parse_offense': undefined method `names' for nil:NilClass (NoMethodError)from C:/PWKit/PuppetDevKit/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.6.0/lib/pdk/validate/puppet/puppet_syntax.rb:58:in `block in parse_output' 

       

      It looks like this occurs when there are no matches to the regex in https://github.com/puppetlabs/pdk/blob/master/lib/pdk/validate/puppet/puppet_syntax.rb#L87

       

      The issue comes in when puppet parser validate has an unrelated error. In this case, it was as follows.

       

      $ puppet parser validate **\*.pp
      C:/PWKit/Puppet/sys/ruby/lib/ruby/gems/2.4.0/gems/puppet-5.5.2-x64-mingw32/lib/puppet/environments.rb:38:in `get!': Could not find a directory environment named 'PUPPET_MASTER_SERVER=' anywhere in the path: C:/ProgramData/PuppetLabs/code/environments. Does the directory exist? (Puppet::Environments::EnvironmentNotFound) 

       

      Can we add a check to ensure that attributes is populated, and if not, exit with the output from puppet parser validate?

       

      Attachments

        Activity

          People

            bryan.jen Bryan Jen
            jarret.lavallee Jarret Lavallee
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support