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

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.4.0
    • Fix Version/s: PUP 4.4.2
    • Component/s: Compiler
    • Labels:
      None
    • Template:
    • Acceptance Criteria:
      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
    • Story Points:
      1
    • Sprint:
      Language 2016-04-06, Language 2016-04-20
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      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

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

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support