puppetlabs / puppetlabs-stdlib

Puppet Labs Standard Library module
http://forge.puppetlabs.com/puppetlabs/stdlib
Apache License 2.0
348 stars 580 forks source link

'stdlib::fqdn_rand_string' parameter 'charset' expects a String value, got Undef #1368

Closed silug closed 1 year ago

silug commented 1 year ago

Describe the Bug

Passing undef as the second argument to fqdn_rand_string results in a compilation error. This worked (unintentionally or not) in previous versions of stdlib.

Expected Behavior

Function returns a random string (as it did in 8.x)

Steps to Reproduce

Steps to reproduce the behavior:

  1. Install stdlib 9.0.0
    [root@40776c2909e5 /]# puppet module install puppetlabs-stdlib -v 9.0.0
    Notice: Preparing to install into /etc/puppetlabs/code/environments/production/modules ...
    Notice: Downloading from https://forgeapi.puppet.com ...
    Notice: Installing -- do not interrupt ...
    /etc/puppetlabs/code/environments/production/modules
    └── puppetlabs-stdlib (v9.0.0)
  2. Call fqnd_rand_string with undef as the second argument
    [root@40776c2909e5 /]# puppet apply -e 'notify { fqdn_rand_string(10, undef, "custom seed"): }'
    Warning: This function is deprecated, please use stdlib::fqdn_rand_string instead. at ["unknown", 1]:["unknown", 0]
    (location: /etc/puppetlabs/code/environments/production/modules/stdlib/lib/puppet/functions/deprecation.rb:35:in `deprecation')
    Error: Evaluation Error: Error while evaluating a Function Call, 'stdlib::fqdn_rand_string' parameter 'charset' expects a String value, got Undef (line: 1, column: 10) on node 40776c2909e5

Environment

Additional Context

This code worked as recently as stdlib 8.6.0.

[root@865c93eff098 /]# puppet module install puppetlabs-stdlib -v 8.6.0
Notice: Preparing to install into /etc/puppetlabs/code/environments/production/modules ...
Notice: Downloading from https://forgeapi.puppet.com ...
Notice: Installing -- do not interrupt ...
/etc/puppetlabs/code/environments/production/modules
└── puppetlabs-stdlib (v8.6.0)
[root@865c93eff098 /]# puppet apply -e 'notify { fqdn_rand_string(10, undef, "custom seed"): }'
Notice: Compiled catalog for 865c93eff098 in environment production in 0.02 seconds
Notice: OhaNI3TjnN
Notice: /Stage[main]/Main/Notify[OhaNI3TjnN]/message: defined 'message' as 'OhaNI3TjnN'
Notice: Applied catalog in 0.00 seconds
jordanbreen28 commented 1 year ago

Thanks for raising this @silug. Looks like this is being addressed in https://github.com/puppetlabs/puppetlabs-stdlib/pull/1367, lets see if we can get it moving along.

silug commented 1 year ago

Thanks for raising this @silug. Looks like this is being addressed in #1367, lets see if we can get it moving along.

Sorry @jordanbreen28, I completely missed that PR. It looks like the fix was merged in https://github.com/puppetlabs/puppetlabs-stdlib/commit/24a0f2138f0fa3ef535b3424c314324ff3955680.

Thanks!