The Puppet Labs Issue Tracker has Moved:

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using See the following page for information on filing tickets with JIRA:

Bug #5662

Parsedfile provider does not work with composite keys

Added by Stefan Schulte over 5 years ago. Updated about 5 years ago.

Status:ClosedStart date:12/23/2010
Priority:NormalDue date:
Assignee:Stefan Schulte% Done:


Target version:2.6.7
Affected Puppet version:2.6.0 Branch:

We've Moved!

Ticket tracking is now hosted in JIRA:


When one uses the parsedfileprovider for a type with multiple key_attributes the propertyhash is not filled with all keyattributes.

I found the bug while creating the following parsedfile provider:

# This provider parses /etc/services. name and protocol are key_attributes
record_line :parsed, :fields => %w{name number protocol port_aliases description},
  :optional   => %w{port_aliases description},
  :match      => /^(\S*)\s+(\d*)\/(\S*)\s*(.*?)?\s*(?:#\s*(.*))?$/,
  :post_parse => proc { |hash|
    # Remark: I can see that hash[:protocol] exists and is valid
    hash[:protocol] = hash[:protocol].intern if hash[:protocol]
    # [... some more ruby code that does not touch hash[:protocol] in any way ...]
  :to_line => proc { |hash|
    # :protocol is NOT set here thus raising an error
    [:name, :number, :protocol].each do |n|
      raise Puppet::Error, "#{n} is a required attribute for port but not included in #{hash.inspect}" unless hash[n] and hash[n] != :absent
    # [... some more ruby code to build a /etc/service line ..]

Raised error:

Could not evaluate: protocol is a required attribute for port but not included in
{:on_disk=>true, :number=>"25", :target=>"/etc/services", ensure=>:present, :name=>"foo", :record_type=>:parsed

If I understand the parsedfileprovider correctly this is causing the bug:

  • The create method in puppet/provider/parsedfile.rb is putting all validproperties in the property_hash hash
  • Keyattributes are parameters and thus are not landing in the hash so name and protocol are not stored in that hash
  • The flush method in parsedfile.rb has some special handling for name because it does a final @property_hash[:name] ||=
  • The flush method does not treat other key_attributes in this special way so all other keyattributes are not present in the to_line hook,

Related issues

Blocks Puppet - Feature #5660: Puppet should handle port entries in /etc/services with a... Tests Insufficient 12/23/2010


#1 Updated by Stefan Schulte over 5 years ago

  • % Done changed from 0 to 100
  • Branch set to

my proposed patch:


#2 Updated by James Turnbull over 5 years ago

  • Status changed from Unreviewed to In Topic Branch Pending Review
  • Target version set to 2.7.x

#3 Updated by Jesse Wolfe about 5 years ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release
  • Target version changed from 2.7.x to 2.6.x

I’d be happier if the unit test changes were in the same commit as the code change, but I’m not going to quibble.

Available in as of commit:6260687ee00f409c4b718f7e6f244ae844dab7d3

#4 Updated by James Turnbull about 5 years ago

  • Status changed from Merged - Pending Release to Closed
  • Target version changed from 2.6.x to 2.6.7

Also available in: Atom PDF