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

assigning undef/NULL value to class parameters via Hiera doesn't work reliably

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Won't Fix
    • Affects Version/s: PUP 4.2.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:
      • Puppet 4.2
      • Hiera 3
    • Template:

      Description

      Hi everyone,

      I'm not sure whether this is a Puppet or a Hiera issue, so if I'm wrong here just tell me or move the issue around .

      Assuming the following construction:

      class foo (
      	Optional[String[1]] $myval = 'something',
      ) {
      	[... doesn't matter ...]
      }
      

      Using Hiera, Puppet does an automatic parameter lookup for class variables.
      This is working great for "usual" Strings, Integers, Booleans, ... but partially breaks for undef/NULL. To specify "breaks": it looks like as if parameter is assigned a undef/NULL value, it is entirely omitted and not passed to Puppet at all, which leads to the default values.

      To demonstrate this:

      Hiera with a yaml backend:

      foo::myval: 'some string'
      # $myval == 'some string' (as expected and desired)
       
      foo::myval: ''
      # evaluation fails (as expected and desired)
       
      foo::myval: 3
      # evaluation fails (as expected and desired)
       
      foo::myval: NULL
      # $myval == 'something' (!!! this is the default value and NOT undef as it should be !!!)
      

      I consider this to be a bug as assigning a undef/NULL value to a hash-key is working fine:

      class foo (
      	Struct[{
      		myval => Optional[String[1]],
      	}] $myhash = {
      		myval => 'foo',
      	},
      ) {
      	[... doesn't matter ...]
      }
      

      foo::myhash:
        myval: 'some string'
      # $myhash['myval'] == 'some string' (as expected and desired)
       
      foo::myhash:
        myval: ''
      # evaluation fails (as expected and desired)
       
      foo::myhash:
        myval: 3
      # evaluation fails (as expected and desired)
       
      foo::myhash: NULL
      # $myhash['myval'] == 'foo' (!!! this is the default value and NOT undef as it should be (or actually it should be throwing an error as the key doesn't exist) !!!)
       
      foo::myhash:
        myval: NULL
      # $myhash['myval'] is undef (!!! as expected and desired !!!)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                akovtunenko Alexander
                Reporter:
                chb Christoph Bihler
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support