The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #3129

Problem using a number as as class name

Added by Mike Culbertson about 4 years ago. Updated over 1 year ago.

Status:AcceptedStart date:01/30/2010
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:RAL
Target version:-
Affected Puppet version:0.25.3 Branch:
Keywords:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This ticket may be automatically exported to the PUP project on JIRA using the button below:


Description

I’ve run into what looks like a bug when using a number as a class name in a nested class. There are no errors while parsing the class itself, but when the manifest gets to the point where I actually include the class, this happens:

err: Could not parse for environment development: Syntax error at ':'; expected '}' at /etc/puppet/development/modules/sol/manifests/init.pp:77

The include line is:

include sol::network::10

If I double-quote the class name, the error does not occur. I’ve attached debug+trace logs from puppetd, puppetmasterd and a (slightly redacted) copy of the init.pp from the module in question. This is the only manifest in this particular module. However, I do have numeric class names elsewhere in other modules, and they all erorred out the same way until I quoted the class names, so it does not appear to be unique to this module or class.

TIA

-Mike

puppetd.log - The client hostname is "abby" (5.58 KB) Mike Culbertson, 01/30/2010 01:44 am

puppetmaster.log - Server hostname is the default "puppet" (12.9 KB) Mike Culbertson, 01/30/2010 01:44 am

sol-init.pp (2.89 KB) Mike Culbertson, 01/30/2010 01:44 am

puppetd.log - test run with class name set to "10" (5.58 KB) Mike Culbertson, 01/30/2010 02:47 am

puppetmaster.log - test run with class name set to "10" (12.9 KB) Mike Culbertson, 01/30/2010 02:49 am


Related issues

Related to Puppet - Bug #1274: class names cannot begin with a digit Closed
Related to Puppet - Bug #7523: Refactor the grammar to reduce duplication Closed 05/13/2011
Related to Puppet - Bug #10506: Naming rules are inconsistent Accepted 11/03/2011

History

#1 Updated by Mike Culbertson about 4 years ago

Just realized I attached the wrong init.pp, but in the process it showed the same bug in another location. I had temporarily renamed the class to the fully qualified “solaris::network::10” when it should be just “10”, and I forgot to switch it back before generating the logs. However, in the first set of attached logs, it looks like puppetmaster is throwing an error when the class name is nested and includes a number, so it’s not only happening on the “include” line. Compare to the second set of logs.

#2 Updated by Mike Culbertson about 4 years ago

  • File deleted (puppetmaster.log)

#3 Updated by Mike Culbertson about 4 years ago

getting tired, wrong log :P

#4 Updated by James Turnbull about 4 years ago

  • Category set to RAL
  • Status changed from Unreviewed to Investigating
  • Assignee set to James Turnbull
  • Priority changed from High to Normal
  • Target version set to 0.25.5

#5 Updated by James Turnbull about 4 years ago

  • Status changed from Investigating to Needs Decision
  • Assignee changed from James Turnbull to Luke Kanies
class sol {
    notice("sol")

 class net {
    notice("net")

  class bob { 
    notice("bob")
  }
  class 10 {
    notice("10")
  }
 }
}

class one::two::three {

    notice("one/two/three")
}

#class "one::two::3" {
#
#        notice("one/two/3")
#}

class sol {
    class 3 {
        notice("3")
    }
}

#include sol
#include net
#include 10
#include sol::net
#include "sol::net::10"
#include sol::net::bob
#include one::two::three
#include one::two::3
include sol::3

The above manifests tries variations of this:

  1. Nested classes with numeric classes:
class one { 
 class 3 { }
}

These work if quoted:

include "one::3"

But not if not quoted:

include one::3
  1. Fully-qualified classes:
class one::3 {}
class "one::3" {}

Where the second class is numeric – don’t work quoted or not in an include.

Could not parse for environment production: Syntax error at 'sol::3' at /tmp/number.pp:32

So I am guessing this is related to the regex in CLASSREF & NAME in the lexer but not sure what behaviour we should support. I am guessing if we support numeric class names then we should support then we should support them nested.

Perhaps the lexer regex should be:

%r{([a-z0-9][-\w]*)?(::[a-z0-9][-\w]*)+} => :CLASSNAME, # Require '::' in the class name, else we'd compete with NAME

This would allow example 1 above to work – quoted or unquoted.

Example 2 would still fail – not sure how to fix that? Luke/Markus?

#6 Updated by Luke Kanies about 4 years ago

  • Status changed from Needs Decision to Accepted
  • Assignee deleted (Luke Kanies)
  • Target version changed from 0.25.5 to 2.7.x

I just looked into it, and we have a NUMBER token but the grammar doesn’t ever mention it, because it just returns NAME. I.e., we should just get rid of it and have NAME be entirely alphanumber, including plain numbers.

This should be easy and work fine.

Obviously not a 0.25.5 ticket, though, unless this is a new bug.

#7 Updated by Andrew Parker over 1 year ago

  • Target version deleted (2.7.x)

Also available in: Atom PDF