Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-11172

undefined method `[]' for nil:NilClass when handling SemanticPuppet::Dependency::UnsatisfiableGraph

    XMLWordPrintable

Details

    • Night's Watch
    • 2
    • NW - 2021-08-11
    • Needs Assessment
    • Bug Fix
    • `puppet module install` could break in some cases when dependencies could not be resolved. The error cases are now treated and puppet emits an error message in this case.
    • Needs Assessment

    Description

      Installed Software

      1. rpm -qa |grep -E '(puppet|pdk)'
        puppet7-release-7.0.0-2.el7.noarch
        puppet-agent-7.8.0-1.el7.x86_64
        pdk-2.1.1.0-1.el7.x86_64

       

      Steps to reproduce

      I am trying to deploy a custom puppet module and I went through:

      rake build:pdk

      then:

      puppet module install ./path/to/OUR_MODULE_NAME-3.0.0.tar.gz --debug

       

      Desired Behavior:

      Our module with all dependencies be installed

      Actual Behavior:

      Code exits non-zero trying to call ..constraints[*nil*].first[1]

       

      It seems like the error is caused because of a logical issue at:

      https://github.com/puppetlabs/puppet/blob/main/lib/puppet/module_tool/applications/installer.rb#L141

      With some janky

      {{ rescue SemanticPuppet::Dependency::UnsatisfiableGraph => e}}
        unsatisfied = nil
        pp 'e'
        pp e
        pp 'e.respond_to?(:unsatisfied)'
        pp e.respond_to?(:unsatisfied)
        pp 'e.respond_to?(:unsatisfied)'
        pp e.respond_to?(:unsatisfied)

      The output below shows that `e` does respond to :unsatisfied, but e.unsatisfied is nil, so when it's called on L167 it fails

       

      $ puppet module install ./pkg/OUR_MODULE_NAME-3.0.0.tar.gz --debug
      Debug: Runtime environment: puppet_version=7.8.0, ruby_version=2.7.3, run_mode=user, default_encoding=UTF-8
      Notice: Preparing to install into /home/vagrant/.puppetlabs/etc/code/modules ...
      Debug: Could not find library 'archive/tar/minitar' required to enable feature 'minitar'
      Debug: Executing: 'gzip -dc /REDACTED/pkg/OUR_MODULE_NAME-3.0.0.tar.gz | tar xof -'
      Debug: Executing: 'find . -type d -exec chmod 755 {} +'
      Debug: Executing: 'find . -type f -exec chmod u+rw,g+r,a-st {} +'
      Debug: Executing: 'chown -R 1000:1000 .'
      Debug: Unpacked local tarball to /home/vagrant/.puppetlabs/opt/puppet/cache/OUR_MODULE_NAME/cache/local-tarball20210721-26316-1jpeh2d
      Notice: Downloading from https://forgeapi.puppet.com ...
      Debug: Could not find library 'pe_license' required to enable feature 'pe_license'
      Debug: Creating new connection for https://forgeapi.puppet.com:443
      Debug: Starting connection for https://forgeapi.puppet.com:443
      Debug: Using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384
      Debug: HTTP GET https://forgeapi.puppet.com/v3/releases?module=cds-puppet&sort_by=version&exclude_fields=readme%2Cchangelog%2Clicense%2Curi%2Cmodule%2Ctags%2Csupported%2Cfile_size%2Cdownloads%2Ccreated_at%2Cupdated_at%2Cdeleted_at returned 200 OK
      Debug: Caching connection for https://forgeapi.puppet.com:443
      {{Debug: Using cached connection for [https://forgeapi.puppet.com:443

      https://forgeapi.puppet.com/]}}<SOME OUTPUT OMITTED>

      Debug: Caching connection for https://forgeapi.puppet.com:443
      Debug: Using cached connection for https://forgeapi.puppet.com:443
      Debug: HTTP GET https://forgeapi.puppet.com/v3/releases?module=thias-postfix&sort_by=version&exclude_fields=readme%2Cchangelog%2Clicense%2Curi%2Cmodule%2Ctags%2Csupported%2Cfile_size%2Cdownloads%2Ccreated_at%2Cupdated_at%2Cdeleted_at returned 200 OK
      Debug: Caching connection for https://forgeapi.puppet.com:443
      Info: Resolving dependencies ...

      "e"
      #<SemanticPuppet::Dependency::UnsatisfiableGraph: Could not find satisfying releases for OUR_MODULE_NAME>
      "e.unsatisfied"
      nil
      "e.respond_to?(:unsatisfied)"
      true

      Error: undefined method `[]' for nil:NilClass
      Error: Try 'puppet help module install' for usage

       

      Bonus Info

      • I am only seeing this now because I have finally been able to schedule time on upgrading from puppet 5, and am going straight to 7.
      • rake works:
        • check
        • rubocop
        • lint
        • metadata_lint
        • validate

      Attachments

        Issue Links

          Activity

            People

              gheorghe.popescu Gheorghe Popescu
              pingram Phil
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support