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

enhance versioncmp() error checking as it only accepts strings

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • PUP 4.0.0
    • PUP 4.3.0
    • Language
    • None
    • 1
    • Language 2015-08-05
    • New Feature
    • The versioncmp() function now type checks its arguments (they must be Strings). Before this, if something other that Strings were given the result could be a hard to understand error message. Now it is made clear it is a type mismatch problem.

    Description

      versioncmp() appears to be completely broken under 4.1.0 (have not tested 4.0.0) with strings in variables that "look" like floating point values. Unfortunately, the X.Y version format is fairly popular with cli utils and this bug caught me when testing util version facts. Eg.,

      $ be puppet --version
      4.1.0
      $ be puppet apply -e 'versioncmp("5.43", "5.43")'
      Notice: Compiled catalog for shinything.cisco in environment production in 0.31 seconds
      Notice: Applied catalog in 0.01 seconds
      $ be puppet apply -e '$foo=5.43; versioncmp($foo, "5.43")'
      Error: Evaluation Error: Error while evaluating a Function Call, undefined method `scan' for 5.43:Float  at line 1:12 on node shinything.cisco
      

      I've investigated the versioncmp() function and Puppet::Util::Package.versioncmp() and they seem to be correct. I suspect the problem is with how input for "3x" function is munged. stdlib's type3x() function does consider my test string to be a float.

      $ be puppet apply --modulepath=./modules -e 'notify{ type3x("5.43"): }'
      Notice: Compiled catalog for shinything.cisco in environment production in 0.29 seconds
      Notice: float
      Notice: /Stage[main]/Main/Notify[float]/message: defined 'message' as 'float'
      Notice: Applied catalog in 0.01 seconds
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jhoblitt Joshua Hoblitt
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support