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

No title provided and "" is not a valid resource reference - caused by create_resources() not filtering out undefs

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.5.0, PUP 4.5.1
    • Fix Version/s: PUP 4.5.2
    • Component/s: None
    • Labels:
    • Environment:

      Puppet 4.5.0

    • Template:
    • Story Points:
      1
    • Sprint:
      Language 2016-06-15
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      In PUP-6028 error handling for attempts to form relationships with undef resources was improved. This in turn led to a problem with code using {{create_resources}} and the stdlib functions {{ensure_resource}}, {{ensure_resources}}, and {{ensure_packages}} as this combination could feed an undef resource reference into the catalog, and such are now always treated as an error.

      The problem manifests itself as the error message:
      {code}
      No title provided and "" is not a valid resource reference
      {code}
      Show
      In PUP-6028 error handling for attempts to form relationships with undef resources was improved. This in turn led to a problem with code using {{create_resources}} and the stdlib functions {{ensure_resource}}, {{ensure_resources}}, and {{ensure_packages}} as this combination could feed an undef resource reference into the catalog, and such are now always treated as an error. The problem manifests itself as the error message: {code} No title provided and "" is not a valid resource reference {code}

      Description

      Since PUP-6028, catalog compilation now fails when a resource has the require or before metaparameters set to undef.

      This behaviour was relied upon in the puppetlabs-postgresql module at https://github.com/puppetlabs/puppetlabs-postgresql/blob/4.7.1/manifests/server/extension.pp#L57-L58 where the value of the metaparams is worked out in the manifest and can be undef.

      A simple reproducer, at commit eff7ac6 or master:

      $ bin/puppet apply -e 'notify { "a": require => undef }' --trace
      Error: No title provided and "" is not a valid resource reference on node cobalt
      /home/dcleal/code/puppet/puppet/lib/puppet/resource.rb:544:in `extract_type_and_title'
      /home/dcleal/code/puppet/puppet/lib/puppet/resource.rb:529:in `type_and_title'
      /home/dcleal/code/puppet/puppet/lib/puppet/resource/catalog.rb:353:in `resource'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:33:in `block in validate_relationship'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:32:in `each'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:32:in `validate_relationship'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:10:in `block (2 levels) in validate'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/resource.rb:51:in `block in eachparam'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/resource.rb:50:in `each'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/resource.rb:50:in `eachparam'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:8:in `block in validate'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:6:in `each'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:6:in `validate'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:217:in `block in validate_catalog'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:217:in `each'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:217:in `validate_catalog'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:205:in `block (2 levels) in compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/profiler.rb:51:in `profile'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:204:in `block in compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/context.rb:65:in `override'
      /home/dcleal/code/puppet/puppet/lib/puppet.rb:240:in `override'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:167:in `compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:35:in `compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:265:in `block (2 levels) in compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/profiler.rb:51:in `profile'
      /home/dcleal/code/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:263:in `block in compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/util.rb:223:in `block in benchmark'
      /home/dcleal/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
      /home/dcleal/code/puppet/puppet/lib/puppet/util.rb:222:in `benchmark'
      /home/dcleal/code/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:261:in `compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:53:in `find'
      /home/dcleal/code/puppet/puppet/lib/puppet/indirector/indirection.rb:194:in `find'
      /home/dcleal/code/puppet/puppet/lib/puppet/application/apply.rb:256:in `block in main'
      /home/dcleal/code/puppet/puppet/lib/puppet/context.rb:65:in `override'
      /home/dcleal/code/puppet/puppet/lib/puppet.rb:240:in `override'
      /home/dcleal/code/puppet/puppet/lib/puppet/application/apply.rb:225:in `main'
      /home/dcleal/code/puppet/puppet/lib/puppet/application/apply.rb:170:in `run_command'
      /home/dcleal/code/puppet/puppet/lib/puppet/application.rb:344:in `block in run'
      /home/dcleal/code/puppet/puppet/lib/puppet/util.rb:540:in `exit_on_fail'
      /home/dcleal/code/puppet/puppet/lib/puppet/application.rb:344:in `run'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/command_line.rb:128:in `run'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/command_line.rb:72:in `execute'
      /home/dcleal/code/puppet/puppet/bin/puppet:5:in `<main>'
      /home/dcleal/code/puppet/puppet/lib/puppet/resource.rb:544:in `extract_type_and_title'
      /home/dcleal/code/puppet/puppet/lib/puppet/resource.rb:529:in `type_and_title'
      /home/dcleal/code/puppet/puppet/lib/puppet/resource/catalog.rb:353:in `resource'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:33:in `block in validate_relationship'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:32:in `each'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:32:in `validate_relationship'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:10:in `block (2 levels) in validate'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/resource.rb:51:in `block in eachparam'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/resource.rb:50:in `each'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/resource.rb:50:in `eachparam'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:8:in `block in validate'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:6:in `each'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:6:in `validate'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:217:in `block in validate_catalog'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:217:in `each'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:217:in `validate_catalog'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:205:in `block (2 levels) in compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/profiler.rb:51:in `profile'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:204:in `block in compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/context.rb:65:in `override'
      /home/dcleal/code/puppet/puppet/lib/puppet.rb:240:in `override'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:167:in `compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/parser/compiler.rb:35:in `compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:265:in `block (2 levels) in compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/profiler.rb:51:in `profile'
      /home/dcleal/code/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:263:in `block in compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/util.rb:223:in `block in benchmark'
      /home/dcleal/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
      /home/dcleal/code/puppet/puppet/lib/puppet/util.rb:222:in `benchmark'
      /home/dcleal/code/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:261:in `compile'
      /home/dcleal/code/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:53:in `find'
      /home/dcleal/code/puppet/puppet/lib/puppet/indirector/indirection.rb:194:in `find'
      /home/dcleal/code/puppet/puppet/lib/puppet/application/apply.rb:256:in `block in main'
      /home/dcleal/code/puppet/puppet/lib/puppet/context.rb:65:in `override'
      /home/dcleal/code/puppet/puppet/lib/puppet.rb:240:in `override'
      /home/dcleal/code/puppet/puppet/lib/puppet/application/apply.rb:225:in `main'
      /home/dcleal/code/puppet/puppet/lib/puppet/application/apply.rb:170:in `run_command'
      /home/dcleal/code/puppet/puppet/lib/puppet/application.rb:344:in `block in run'
      /home/dcleal/code/puppet/puppet/lib/puppet/util.rb:540:in `exit_on_fail'
      /home/dcleal/code/puppet/puppet/lib/puppet/application.rb:344:in `run'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/command_line.rb:128:in `run'
      /home/dcleal/code/puppet/puppet/lib/puppet/util/command_line.rb:72:in `execute'
      /home/dcleal/code/puppet/puppet/bin/puppet:5:in `<main>'
      

      Previously this worked (commit f14b653):

      $ bin/puppet apply -e 'notify { "a": require => undef }' --trace
      Notice: Compiled catalog for cobalt in environment production in 0.06 seconds
      Notice: a
      Notice: /Stage[main]/Main/Notify[a]/message: defined 'message' as 'a'
      Notice: Applied catalog in 0.04 seconds
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                domcleal Dominic Cleal
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support