Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
PUP 5.4.0
-
Coremunity
-
Needs Assessment
-
Reviewed
-
34700
-
1
-
Bug Fix
-
-
Needs Assessment
Description
Puppet Version:2018.1.5
Puppet Server Version:5.5.8
OS Name/Version: RHEl and Solaris
Desired Behavior:
Convert "08" from a string to an integer successfully on puppet run.
Actual Behavior:
Fails to convert "08" from a string to an integer on a puppet run.
Some of our newly added code was failing on what seems to be a valid String -> Integer conversion.
A minimal case to reproduce:
This, which is essentially the same as one of the examples in the docs (https://puppet.com/docs/puppet/5.5/function.html#conversion-to-integer) works:
- puppet apply -e 'notify { "message": message => Integer("010", 10) }'
Notice: Compiled catalog for denga02l.unix.anz in environment production in 0.05 seconds
Notice: 10
Notice: /Stage[main]/Main/Notify[message]/message: defined 'message' as 10
Notice: Applied catalog in 0.26 seconds
As you can see the "radix" argument to specify base 10 makes it it correctly interpret the string as a decimal number
- puppet apply -e 'notify { "message": message => Integer("07", 10) }'
Notice: Compiled catalog for pe-201817-master.puppetdebug.vlan in environment production in 0.11 seconds
Notice: 7
Notice: /Stage[main]/Main/Notify[message]/message: defined 'message' as 7
Notice: Applied catalog in 0.30 seconds
But this fails:
- puppet apply -e 'notify { "message": message => Integer("08", 10) }'
Error: Evaluation Error: Error while evaluating a Function Call, 'new' The string '08' cannot be converted to Integer (line: 1, column: 33) on node denga02l.unix.anz
Since the first example correctly interprets the string I suspect that there are two passes over it - one of which is trying to interpret the value as octal, and the second which is doing the actual conversion.
This happens on both RHEL and Solaris systems