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

Validate and error if a class or define is given a name starting with ::

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • PUP 4.5.0
    • PUP 4.6.0
    • None
    • None
    • Hide

      That

      class ::foo { }
      define ::foo { }
      function ::foo() { }
      type ::Foo = Integer
      application ::foo { }  # requires --app_management
      

      All lead to an error being raised.

      Show
      That class ::foo { } define ::foo { } function ::foo() { } type ::Foo = Integer application ::foo { } # requires --app_management All lead to an error being raised.
    • 1
    • Language 2016-06-15, Language 2016-06-29
    • Bug Fix
    • Naming a class or a define with a leading :: (making the name absolute) lead to not being able to use that class/define. Now, such names are treated as illegal.

    Description

      Update


      It is not allowed to use a a leading :: (making a name absolute) when defining a class or a user defined resource type.
      Nested definitions are named with a leading namespace from its container. It is not allowed to break out of that naming convention, and it is meaningless to use :: before top level definitions.

      Given that it also does not work to use definitions named with a leading :: there is no backwards compatibility issue - only that error comes at compile time instead of when trying to use such a definition.

      Original


      If you create a class with a name that includes two colons, it appears (as it is difficult to ascertain) to generate a class with an illegal fully qualified name. You can then no longer reference the class because it is an illegal fully qualified name.

      $ bundle exec puppet apply -e 'class ::passwd {} include passwd'
      Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::passwd for build03.nelson.va  at line 1:19 on node build03.nelson.va
       
      $ bundle exec puppet apply -e 'class ::passwd {} include ::passwd'
      Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::passwd for build03.nelson.va  at line 1:19 on node build03.nelson.va
       
      $ bundle exec puppet apply -e 'class ::passwd {} include ::::passwd'
      Error: Could not parse for environment production: Illegal fully qualified name  at line 1:29 on node build03.nelson.va
       
      $ bundle exec puppet apply -e 'class passwd {} include passwd'
      Notice: Compiled catalog for build03.nelson.va in environment production in 0.05 seconds
      Notice: Applied catalog in 0.01 seconds
       
      $ bundle exec puppet apply -e 'class passwd {} include ::passwd'
      Notice: Compiled catalog for build03.nelson.va in environment production in 0.05 seconds
      Notice: Applied catalog in 0.01 seconds
       
      $ bundle exec puppet --version
      4.5.0
      

      I feel that attempting to define a class in a way that generates an illegal fully qualified name should generate an error during the definition, rather than during attempts to use it. This would be more clear to authors, earlier in their development process.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rnelson0@gmail.com Rob Nelson
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support