puppetlabs/puppet · error · Puppet::ParseError

equality_include_type = false cannot be combined with non em

Error message

equality_include_type = false cannot be combined with non empty equality specification

What it means

By default Object type equality includes a type check (equality_include_type defaults to true). Setting equality_include_type => false means two instances of different types with equal attribute values compare equal, which is only meaningful with the default equality (all non-constant attributes). Combining it with an explicit, non-empty equality list is contradictory and raises Puppet::ParseError.

Source

Thrown at lib/puppet/pops/types/p_object_type.rb:789

      @functions = func_specs.to_h do |key, func_spec|
        func_spec = { KEY_TYPE => TypeAsserter.assert_instance_of(nil, TYPE_FUNCTION_TYPE, func_spec) { "function #{label}[#{key}]" } } unless func_spec.is_a?(Hash)
        func = PFunction.new(key, self, func_spec)
        name = func.name
        raise Puppet::ParseError, _("%{label} conflicts with attribute with the same name") % { label: func.label } if @attributes.include?(name)

        [name, func.assert_override(parent_members)]
      end.freeze
    end

    @equality_include_type = init_hash[KEY_EQUALITY_INCLUDE_TYPE]
    @equality_include_type = true if @equality_include_type.nil?

    equality = init_hash[KEY_EQUALITY]
    equality = [equality] if equality.is_a?(String)
    if equality.is_a?(Array)
      unless equality.empty?
        # TRANSLATORS equality_include_type = false should not be translated
        raise Puppet::ParseError, _('equality_include_type = false cannot be combined with non empty equality specification') unless @equality_include_type

        parent_eq_attrs = nil
        equality.each do |attr_name|
          attr = parent_members[attr_name]
          if attr.nil?
            attr = @attributes[attr_name] || @functions[attr_name]
          elsif attr.is_a?(PAttribute)
            # Assert that attribute is not already include by parent equality
            parent_eq_attrs ||= parent_object_type.equality_attributes
            if parent_eq_attrs.include?(attr_name)
              including_parent = find_equality_definer_of(attr)
              raise Puppet::ParseError, _("%{label} equality is referencing %{attribute} which is included in equality of %{including_parent}") %
                                        { label: label, attribute: attr.label, including_parent: including_parent.label }
            end
          end

          unless attr.is_a?(PAttribute)
            if attr.nil?

View on GitHub (pinned to e227c27540)

Solutions

  1. Remove the equality_include_type => false line and keep the explicit equality list (type check stays on)
  2. Or keep equality_include_type => false and drop the explicit equality list, accepting default equality over all non-constant attributes

Example fix

# before
type MyApp::Id = Object[{
  equality_include_type => false,
  equality => ['id']
}]

# after
type MyApp::Id = Object[{
  equality => ['id']        # keep the default equality_include_type => true
}]
Defensive patterns

Strategy: validation

Validate before calling

# reject the contradictory combination up front
if equality.is_a?(Array) && !equality.empty? && equality_include_type == false
  raise 'equality_include_type = false cannot be combined with an explicit equality list'
end

Try / catch

begin
  Puppet::Pops::Types::PObjectType.new(name, init_hash)
rescue Puppet::ParseError => e
  raise unless e.message =~ /equality_include_type = false/
  raise  # drop either the flag or the explicit equality list
end

Prevention

When it happens

Trigger: A single type declaration containing both equality_include_type => false and equality => ['id'] (or a one-element String form equality => 'id'). The check fires immediately during type resolution.

Common situations: Copy-pasting an equality block from a type that used default equality; tuning equality semantics without understanding that an explicit list already fixes which members participate; migrating data types between Puppet versions.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/c5cefd78370568dd. Report an issue: GitHub.