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

Puppet log functions should return Undef rather than a Puppet::Util::Log object

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.7.0
    • Fix Version/s: PUP 4.8.0
    • Component/s: None
    • Labels:
      None
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      All of the logging functions (like 'notice', 'debug') leaked a puppet internal value to the Puppet Language. Under rare circumstances the returned value could be used to produce a string value. This is now fixed so that the logging functions always returns {{undef}} as intended.
      Show
      All of the logging functions (like 'notice', 'debug') leaked a puppet internal value to the Puppet Language. Under rare circumstances the returned value could be used to produce a string value. This is now fixed so that the logging functions always returns {{undef}} as intended.

      Description

      Currently, the log functions (like lib/puppet/functions/alert.rb) return an instance of a Puppet::Util::Log object. Some context from Henrik:

      [9:26 AM] Henrik Lindberg: so, it returns some kind of Log object, which is not good when these functions are called from puppet as that object leaks into the puppet world
      [9:27 AM] Henrik Lindberg: when they were 3x functions there is a general mechanism where all "non r-value" type functions always are made to return nil to puppet
      [9:27 AM] Henrik Lindberg: there is no such thing in 4.x, all functions are rvalue functions, only that they return nil if they have nothing meaningful to return
      [9:29 AM] Henrik Lindberg: now, we may not be able to change the return to Undef actually - because people may call the puppet functions from Ruby and expect to get a Log object
      [9:33 AM] Henrik Lindberg: Problem: if we document it as Undef, it is correct from a spec standoint, and thus it is a bug that it actually returns Log sometimes
      [9:34 AM] Henrik Lindberg: if we document it what it really is Optional[Runtime['ruby', 'Puppet::Util::Log']], that is really confusing, and you cannot really do much with that value
      [9:34 AM] Henrik Lindberg: I think it is best to document it as Undef, and add a ticket that logging functions should return undef and never the log object instance.
      Those that code in ruby and need the Util::Log object should instead do the logging themselves and not call the puppet functions

      These functions now use a log helper in lib/puppet/util/log.rb. They end up returning:

      Puppet::Util::Log.create({:level => level, :source => scope, :message => vals.join(" ")})
      

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  whopper William Hopper
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: