Uploaded image for project: 'Hiera'
  1. Hiera
  2. HI-494

Interpolation of the empty variable %{} has changed

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: HI 3.1.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Story Points:
      1
    • Sprint:
      Language 2016-02-10, Language 2016-02-24
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      A regression where empty interpolations in hiera strings caused garbage text to be inserted has been fixed. This regression was introduced in the 3.x hiera release. Empty interpolations i.e. %{}, %{::} now work, and the trick to get one verbatim interpolation into the string (e.g. "%%{}{environment}" producing the string "%{environment}" is now also again functional.
      Show
      A regression where empty interpolations in hiera strings caused garbage text to be inserted has been fixed. This regression was introduced in the 3.x hiera release. Empty interpolations i.e. %{}, %{::} now work, and the trick to get one verbatim interpolation into the string (e.g. "%%{}{environment}" producing the string "%{environment}" is now also again functional.

      Description

      Sometime between Puppet 3.8.x/Hiera 1.3.x and Puppet 4.3.x/Hiera 3.x, the interpolation result changed for the empty variable %{} Where previously, it would interpolate as an empty string, useful to help prevent interpolation of a variable when generating hiera.yaml or other similar files, it now results in the scope array. Some examples, from https://github.com/hunner/puppet-hiera/issues/108:

      Example 1: Returns the scope array and due to context, it provides the object name.

      # puppet.yaml snippet
      hiera::datadir: '/etc/puppetlabs/code/environments/%%{}{environment}/hiera'
       
      # Results in puppet3/hiera1
      :yaml:
         :datadir: /etc/puppetlabs/code/environments/%{environment}/hiera
       
      # Results in pupppet4/hiera3
      :yaml:
        :datadir: /etc/puppetlabs/code/environments/%#<Hiera::Scope:0x17a1410d>{environment}/hiera
      

      Example 2: Results in the scope array being enumerated at the CLI.

      root@ip-172-30-2-36:~# cat /etc/puppetlabs/code/environments/production/hieradata/common.yaml  | grep -i iptest
      iptest: 'testing "% % {} {::environment}": %%{}{::environment}'
      iptest2: 'testing "% % {::} {::environment}": %%{::}{::environment}'
       
      root@ip-172-30-2-36:~# hiera iptest ::environment=production ::somevar=foo ::someother=bar
      testing "% % {} {::environment}": %{"::environment"=>"production", "::somevar"=>"foo", "::someother"=>"bar"}{::environment}
       
      root@ip-172-30-2-36:~# hiera iptest2 ::environment=production ::somevar=foo ::someother=bar
      testing "% % {::} {::environment}": %{::environment}
      

      It is interesting that %{::} now translates as the empty string, so at least there is a workaround in place.

      This looks like a regression from here. Is this a bug or a feature, given that %{::} wasn't necessarily supposed to be used to help prevent interpolation anyway?

      (pro Jira tip, use &#nnn; for character codes)

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  rnelson0@gmail.com Rob Nelson
                  QA Contact:
                  Sean Griffin
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Zendesk Support