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

PDK crashes completely on bad PDK metadata in metadata.json

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PDK 1.8.0
    • Component/s: None
    • Environment:
    • Template:
    • Method Found:
      Needs Assessment
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      This fixes a bug where PDK will exit unexpectedly with a Ruby exception if the `pdk-version` in metadata.json was null.
    • QA Risk Assessment:
      Needs Assessment

      Description

      Overview
      If you have bad data in a module's metadata.json for PDK's tags, PDK validate metadata will crash with a ruby stack trace

      Steps to reproduce
      1. Create or find a puppet module and edit the PDK metadata to read:

        "data_provider": null,
        "pdk-version": null,
        "template-url": null,
        "template-ref": null
      

      2. pdk validate metadata

      Complete testcase attached

       

      Expected result
      Something along the lines of "invalid metadata for XXX", no stack trace unless in debug mode

      Actual result
      Stack trace:

      geoff@computer:~/tmp/puppet-chown_r$ pdk validate metadata
      /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.7.0/lib/pdk/util.rb:260:in `module_pdk_version': undefined method `split' for nil:NilClass (NoMethodError)
      	from /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.7.0/lib/pdk/cli/util.rb:61:in `module_version_check'
      	from /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.7.0/lib/pdk/cli/validate.rb:44:in `block (2 levels) in <module:CLI>'
      	from /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/cri-2.10.1/lib/cri/command.rb:329:in `run_this'
      	from /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/cri-2.10.1/lib/cri/command.rb:269:in `run'
      	from /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/cri-2.10.1/lib/cri/command.rb:287:in `run'
      	from /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.7.0/lib/pdk/cli.rb:18:in `run'
      	from /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.7.0/exe/pdk:6:in `<top (required)>'
      	from /opt/puppetlabs/pdk/private/ruby/2.4.4/bin/pdk:23:in `load'
      	from /opt/puppetlabs/pdk/private/ruby/2.4.4/bin/pdk:23:in `<main>'
      

      Workaround
      Update the metadata to known good version or remove it and re-run pdk convert

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                tim.sharpe Tim Sharpe
                Reporter:
                geoff@declarativesystems.com Geoff Williams
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: