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

Hiera hash keys are being converted to strings recursively

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.9.0, PUP 4.9.1, PUP 4.9.2, PUP 4.9.3, PUP 4.9.4, PUP 4.10.0, PUP 4.10.1
    • Fix Version/s: PUP 4.10.2, PUP 5.0.0
    • Component/s: None
    • Template:
    • Epic Link:
    • Sub-team:
    • Team:
      Agent
    • Story Points:
      1
    • Sprint:
      PDE 2017-05-31, Agent 2017-06-14
    • Method Found:
      Needs Assessment
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      A regression was found that from Puppet >= 4.9 hiera data containing Integer or Float keys ended up having those keys converted to String. The intention was to only filter out Ruby Symbol keys. Integer and Float keys in hashes now work as they should,
    • QA Risk Assessment:
      Automate
    • QA Risk Assessment Reason:
      covered by unit tests, these need extension (see henrik's comment re hash digging)

      Description

      Puppet 4.9+ currently converts hiera hash elements into strings unconditiionally. YAML.load_file() will deserialize say an Integer to a ruby Fixnum, but the function symkeys_to_string converts every key to a string, regardless of whether it is a symbol.

      Here is a simple example:

      $ports = lookup("ports")
       
      $ports.each |$port, $options | {
      	$port_type = type(Integer.new($port), 'generalized')
      	notify { "${port} = ${port_type}":}
      }
      

      common.yaml:

      ports:
        80:
          test: test
        443:
          test: test
      

      And the output:

      Notice: 80 = String
      Notice: /Stage[main]/Main/Notify[80 = String]/message: defined 'message' as '80 = String'
      Notice: 443 = String
      Notice: /Stage[main]/Main/Notify[443 = String]/message: defined 'message' as '443 = String'
      Notice: Applied catalog in 0.02 seconds
      

      This is also a regression in functionality from Puppet <4.8. PR uploaded to https://github.com/puppetlabs/puppet/pull/5912

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                d.cochran Dylan Cochran
                QA Contact:
                Eric Delaney
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support