Issue #12881 has been reported by Jeff McCune. ---------------------------------------- Bug #12881: Improve poor Cron type error message err: Failed to apply catalog: undefined method 'name' for nil:NilClass https://projects.puppetlabs.com/issues/12881
Author: Jeff McCune Status: Unreviewed Priority: Normal Assignee: Jeff McCune Category: cron Target version: 2.7.12 Affected Puppet version: 2.7.12rc1 Keywords: cron type NilClass undefined method Branch: https://github.com/puppetlabs/puppet/pull/537 # Placeholder # This is a placeholder ticket to break out the patch from #12357. On windows I ran into this error with the cron type: err: Failed to apply catalog: undefined method 'name' for nil:NilClass Without this patch, the problem appears to be that the cron type name parameter defaults to the following block: defaultto { Etc.getpwuid(Process.uid).name || "root" } On windows `Etc.getpwuid(Process.uid)` returns `nil`. This patch fixes the problem by binding the object returned by `Etc.getpwuid(Process.uid)` to a variable. We then check if the variable responds to the `name` method, and only send a message to name if so. Otherwise, we return "root" The included spec test will fail if there is a regression in the desired behavior. The expected failure looks like: Failures: 1) Puppet::Type::Cron should default to user => root if Etc.getpwuid(Process.uid) returns nil (#12357) Failure/Error: entry = described_class.new(:name => "test_entry", :ensure => :present) NoMethodError: undefined method `name' for nil:NilClass # ./lib/puppet/type/cron.rb:359:in `default' # ./lib/puppet/type.rb:540:in `set_default' # ./lib/puppet/type.rb:1834:in `set_parameters' # ./lib/puppet/type.rb:1833:in `each' # ./lib/puppet/type.rb:1833:in `set_parameters' # ./lib/puppet/type.rb:1797:in `initialize' # ./spec/unit/type/cron_spec.rb:474:in `new' # ./spec/unit/type/cron_spec.rb:474 -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
