Bug #4692

undefined variables cause :undef to be passed to functions

Added by micah - over 1 year ago. Updated over 1 year ago.

Status:Closed Start date:09/02/2010
Priority:Normal Due date:
Assignee:- % Done:

100%

Category:functions
Target version:2.6.2
Affected Puppet version:2.6.0 Branch:http://github.com/stereotype441/puppet/tree/ticket/2.6.x/4692
Keywords:
Votes: 0

Description

I have upgraded my puppetmaster to 2.6-rc3, and ran a puppet run on one of my clients that is running 0.25.5. i have a manifest that does a: $attrdrives = split($diskdrives_smartattr, “,”), but now with the new puppet 2.6, that gives me an error when the manifest is run:

private method `split' called for :undef:Symbol

This is because the $diskdrives_smartattr variable is empty. Previously this wouldn’t cause this error. I can fix this in my manifest by doing something like putting an if test of the variable:

  if $diskdrives_smartattr {
    $attrdrives = split($diskdrives_smartattr, ",")
    smart::smartattr { $attrdrives: }
  }

Related issues

related to Puppet - Bug #13210: undef changes into '' when passed to function as a param Needs Decision 03/19/2012

History

Updated by James Turnbull over 1 year ago

  • Status changed from Unreviewed to Needs More Information

Could you please show me the —trace —debug output – particularly the stack trace?

Updated by micah - over 1 year ago

It seems like I am only getting this error with my older 0.25.5 clients connecting to the 2.6 puppetmaster. The 2.6 clients are not fully executing their catalog because of a different error, so I cannot say for sure that they dont also run into this, but just at a different point after this other issue. I need to work out that other issue first to be able to say for sure, but its interesting to note that there is a difference here.

On the 0.25.5 clients, this is the stack trace:

/usr/lib/ruby/1.8/puppet/indirector/rest.rb:55:in `deserialize'
/usr/lib/ruby/1.8/puppet/indirector/rest.rb:69:in `find'
/usr/lib/ruby/1.8/puppet/indirector/indirection.rb:202:in `find'
/usr/lib/ruby/1.8/puppet/indirector.rb:51:in `find'
/usr/lib/ruby/1.8/puppet/configurer.rb:208:in `retrieve_new_catalog'
/usr/lib/ruby/1.8/puppet/util.rb:418:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/1.8/puppet/util.rb:417:in `thinmark'
/usr/lib/ruby/1.8/puppet/configurer.rb:207:in `retrieve_new_catalog'
/usr/lib/ruby/1.8/puppet/configurer.rb:104:in `retrieve_catalog'
/usr/lib/ruby/1.8/puppet/configurer.rb:142:in `run'
/usr/lib/ruby/1.8/puppet/agent.rb:53:in `run'
/usr/lib/ruby/1.8/puppet/agent/locker.rb:21:in `lock'
/usr/lib/ruby/1.8/puppet/agent.rb:53:in `run'
/usr/lib/ruby/1.8/sync.rb:230:in `synchronize'
/usr/lib/ruby/1.8/puppet/agent.rb:53:in `run'
/usr/lib/ruby/1.8/puppet/agent.rb:134:in `with_client'
/usr/lib/ruby/1.8/puppet/agent.rb:51:in `run'
/usr/lib/ruby/1.8/puppet/application/puppetd.rb:103:in `onetime'
/usr/lib/ruby/1.8/puppet/application.rb:226:in `send'
/usr/lib/ruby/1.8/puppet/application.rb:226:in `run_command'
/usr/lib/ruby/1.8/puppet/application.rb:217:in `run'
/usr/lib/ruby/1.8/puppet/application.rb:306:in `exit_on_fail'
/usr/lib/ruby/1.8/puppet/application.rb:217:in `run'
/usr/sbin/puppetd:160
err: Could not retrieve catalog from remote server: Error 400 on SERVER: private method `split' called for :undef:Symbol at /etc/puppet/modules/smart/manifests/init.pp:48 on node

Updated by micah - over 1 year ago

  • Affected Puppet version changed from 2.6.0rc3 to 2.6.1rc3

Updated by James Turnbull over 1 year ago

  • Status changed from Needs More Information to Accepted
  • Target version set to 2.6.1

Updated by James Turnbull over 1 year ago

  • Target version changed from 2.6.1 to 2.6.2

Updated by Paul Berry over 1 year ago

  • Assignee set to Paul Berry
  • Affected Puppet version changed from 2.6.1rc3 to 2.6.0

I’ve reproduced this bug in 2.6.x, and confirmed that it is a regression from 0.25.x. Working on a fix.

Updated by Paul Berry over 1 year ago

  • Subject changed from empty factor variable causes private method `split' called for :undef:Symbol to undefined variables cause :undef to be passed to functions
  • Status changed from Accepted to In Topic Branch Pending Review
  • % Done changed from 0 to 100
  • Branch set to http://github.com/stereotype441/puppet/tree/ticket/2.6.x/4692

The problem is that when a function (such as “split”) is called on an undefined variable, :undef is passed to the function.

We hadn’t intended for this to happen. We’d intended for :undef to only be used internally within Puppet to distinguish between undefined variables and variables whose values are the empty string. When executing a function, we should follow the old (0.25.x) contract and pass the empty string for these variables.

I’m submitting a patch that restores the old behavior.

Updated by Matt Robinson over 1 year ago

  • Assignee changed from Paul Berry to Matt Robinson

I’m starting to review this.

Updated by Matt Robinson over 1 year ago

  • Status changed from In Topic Branch Pending Review to Ready For Checkin
  • Assignee deleted (Matt Robinson)

This has already been +1’d on the list and had quite a bit of discussion around it, so I’m moving it to ready for checkin.

Updated by James Turnbull over 1 year ago

  • Status changed from Ready For Checkin to Closed

Pushed in commit:310a5bd7d29bd7b7334eab8975bdc289d8fb50a9 in branch 2.6.x

Updated by Markus Roberts over 1 year ago

Would you believe commit:8cd1540f82cbdf903c164bdbc2c7229e34a4178b

Updated by micah - over 1 year ago

Markus Roberts wrote:

Would you believe commit:8cd1540f82cbdf903c164bdbc2c7229e34a4178b

Wow, “nothing” to see here… move along.

Updated by James Turnbull over 1 year ago

Micah – if you mean the dead link – I’m fixing those this morning. Looks like our GitHub migration to the puppetlabs account did something weird to our Redmine repo collection.

Updated by James Turnbull over 1 year ago

And fixed!

Updated by micah - over 1 year ago

James Turnbull wrote:

Micah – if you mean the dead link – I’m fixing those this morning. Looks like our GitHub migration to the puppetlabs account did something weird to our Redmine repo collection.

Ah, I didn’t even notice that. I was just commenting on the fix itself, which I found here http://github.com/puppetlabs/puppet/commit/8cd1540f82cbdf903c164bdbc2c7229e34a4178b and did this:

argument = stub ‘arg’, :safeevaluate => “nothing” argument = stub ‘arg’, :safeevaluate => [“nothing”]

hence the “nothing” to see here… bad joke, worse now that it is explained. :)

but hey, thanks for fixing the other bits too james.

Also available in: Atom PDF