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

Optional type misinterpreted by epp() and inline_epp() in puppet 4.4.0

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • PUP 4.4.0
    • PUP 4.4.2
    • Compiler
    • None
    • Hide

      notice inline_epp( '<%- |Optional[String[1]] $var=ouch| -%> <%= $var %>',

      { 'var' => undef }

      )

      shall notify "ouch" and not error

      Show
      notice inline_epp( '<%- |Optional[String [1] ] $var=ouch| -%> <%= $var %>', { 'var' => undef } ) shall notify "ouch" and not error
    • 1
    • Language 2016-04-06, Language 2016-04-20
    • Bug Fix
    • A regression in the functions epp, and inline_epp caused given undef values to be treated as missing given arguments.

    Description

      Here is the code to realize the problem.

      inline_epp( '<%- |Optional[String[1]] $var| -%>', { 'var' => undef } )
      

      The value undef is given to the variable var and it should be accepted by the function inline_epp() because the type of var is:

      Optional[String[1]]
      

      which means ok to have a value undef. But with Puppet 4.4.0, we have an error:

      ~# puppet --version
       
      ~# puppet apply /tmp/test.pp 
      Error: Evaluation Error: Error while evaluating a Function Call, lambda: expects a value for parameter 'var' at /tmp/test.pp:1:1 on node puppet.athome.priv
      

      We have exactly the same error with the function epp().

      Note: with Puppet 4.3.2, the same worked correctly:

      ~# puppet --version
      4.3.2
       
      ~# puppet apply /tmp/test.pp 
      Notice: Compiled catalog for middleware.athome.priv in environment production in 0.04 seconds
      Notice: Applied catalog in 0.12 seconds
      

      When doing this (setting a default value):

      # cat pup6064.pp
      notice inline_epp( '<%- |Optional[String[1]] $var=ouch| -%> <%= $var %>', { 'var' => undef } )
      # puppet apply pup6064.pp
      ouch
      

      Clearly shows the regression - EPP now has define/class instantiation call semantics as the

      {undef}

      picks the default.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              flaf Francois Lafont
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support