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

Square braces in title confuse puppet 4 parser

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.2.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Story Points:
      1
    • Sprint:
      Language 2015-06-10, Language 2015-06-24
    • Release Notes:
      Bug Fix

      Description

      If we have two resources where the titles begin with an identical string enclosed in square braces, the puppet 4 parser throws an error that duplicate resources have been declared:

      extern% PUPPET_GEM_VERSION='~> 4.0' be puppet apply -e 'notify { "[foo] bar": } ; notify { "[foo] baz": }'
      Error: Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Notify[[foo] baz] is already declared in file :1; cannot redeclare at line 1  at line 1:27 on node extern.local
      

      It works fine without the square braces however:

      extern% PUPPET_GEM_VERSION='~> 4.0' be puppet apply -e 'notify { "foo bar": } ; notify { "foo baz": }'
      Notice: Compiled catalog for extern.local in environment production in 0.48 seconds
      Notice: foo bar
      Notice: /Stage[main]/Main/Notify[foo bar]/message: defined 'message' as 'foo bar'
      Notice: foo baz
      Notice: /Stage[main]/Main/Notify[foo baz]/message: defined 'message' as 'foo baz'
      Notice: Applied catalog in 0.02 seconds
      

      An example of a unit test failure is in puppetlabs-inifile when run against Puppet 4: https://travis-ci.org/puppetlabs/puppetlabs-inifile/jobs/65406398

      UPDATE & WORKAROUND

      The problem can manifest itself in different ways - even if not getting the error "duplicate resource", the catalog will record the name wrong and it may not be able to later find it, if something else depends on that resource. The underlying problem is a bug in the parsing of a combined type/title as the first right bracket is believed to be the end of the string - e.g. Notify[[foo]bar] ends up as ["Notify", "[foo"] instead of the expected ["Notify", "[foo]bar"]. (In the reported case, both resource end up with the same title as the part after the first right bracket is lost. Other cases may be that the notify is just not found).

      As a workaround until the fix is released, for notify instances it is possible to use a different title and instead set the message e.g.

      notify {'_foo_bar': message = '[foo]bar' }; notify {'_foo_baz': message => '[foo]baz' }
      

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  jonathan.tripathy Jonny (JT) Tripathy
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 10 minutes
                    10m