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

Data in modules interpret nil as {}

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.4.1
    • Fix Version/s: PUP 4.4.3, PUP 4.5.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Story Points:
      1
    • Sprint:
      Language 2016-05-04
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      A regression was fixed where an explicit nil values in hiera data files used in modules and environment was turned into an empty hash by mistake.

      Description

      Given data in a module class:

      class ntp (
        Optional[String] $ticker_file
      ) {
      ...
      }
      

      and hiera data in the module:

      ntp::ticker_file: ~
      

      The nil is interpreted as a hash:

      % puppet lookup --explain --modulepath `pwd` ntp::ticker_file
      Merge strategy first
        Data Binding "hiera"
          No such key: "ntp::ticker_file"
        Data Provider "EnvironmentDataProvider"
          No such key: "ntp::ticker_file"
        Module "ntp" using Data Provider "Hiera Data Provider, version 4"
          ConfigurationPath "/example/ntp/hiera.yaml"
          Merge strategy first
            Data Provider "OS family"
              Path "/example/ntp/data/os/RedHat.yaml"
                Original path: "os/%{facts.os.family}"
                Path not found
            Data Provider "defaults"
              Path "/example/ntp/data/defaults.yaml"
                Original path: "defaults"
                Found key: "ntp::ticker_file" value: {}
            Merged result: {}
        Merged result: {}
      

      While the YAML is correctly interpreted by ruby as a nil:

      % /opt/puppetlabs/puppet/bin/ruby -r yaml -e 'p YAML.load(File.read("ntp/data/defaults.yaml"))["ntp::ticker_file"]'
      nil
      

      And to be clear its puppet the error is:

      Error: Evaluation Error: Error while evaluating a Function Call, Class[Ntp]: parameter 'ticker_file' expects a String value, got Hash
      

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  ripienaar R.I.Pienaar
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: