{"record":{"id":"1aa940e483204223","repo":"puppetlabs/puppet","slug":"label-equality-is-referencing-non-existent-attr","errorCode":null,"errorMessage":"%{label} equality is referencing non existent attribute '%{attribute}'","messagePattern":"%(.+?) equality is referencing non existent attribute '%(.+?)'","errorType":"exception","errorClass":"Puppet::ParseError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/p_object_type.rb","lineNumber":808,"sourceCode":"\n        parent_eq_attrs = nil\n        equality.each do |attr_name|\n          attr = parent_members[attr_name]\n          if attr.nil?\n            attr = @attributes[attr_name] || @functions[attr_name]\n          elsif attr.is_a?(PAttribute)\n            # Assert that attribute is not already include by parent equality\n            parent_eq_attrs ||= parent_object_type.equality_attributes\n            if parent_eq_attrs.include?(attr_name)\n              including_parent = find_equality_definer_of(attr)\n              raise Puppet::ParseError, _(\"%{label} equality is referencing %{attribute} which is included in equality of %{including_parent}\") %\n                                        { label: label, attribute: attr.label, including_parent: including_parent.label }\n            end\n          end\n\n          unless attr.is_a?(PAttribute)\n            if attr.nil?\n              raise Puppet::ParseError, _(\"%{label} equality is referencing non existent attribute '%{attribute}'\") % { label: label, attribute: attr_name }\n            end\n\n            raise Puppet::ParseError, _(\"%{label} equality is referencing %{attribute}. Only attribute references are allowed\") %\n                                      { label: label, attribute: attr.label }\n          end\n          if attr.kind == ATTRIBUTE_KIND_CONSTANT\n            raise Puppet::ParseError, _(\"%{label} equality is referencing constant %{attribute}.\") % { label: label, attribute: attr.label } + ' ' +\n                                      _(\"Reference to constant is not allowed in equality\")\n          end\n        end\n      end\n      equality.freeze\n    end\n    @equality = equality\n\n    @checks = init_hash[KEY_CHECKS]\n    init_annotatable(init_hash)\n  end","sourceCodeStart":790,"sourceCodeEnd":826,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/p_object_type.rb#L790-L826","documentation":"Every name in an Object type's explicit equality list must resolve to an attribute - looked up first in the parent members, then in the type's own attributes and functions. When a listed name resolves to nothing at all, Puppet::ParseError reports that equality references a non-existent attribute.","triggerScenarios":"equality => ['nam'] where the declared attribute is name; referencing an attribute that was deleted or renamed in a refactor; referencing an attribute of a sibling type rather than a parent.","commonSituations":"Typos in equality lists; renaming attributes without updating equality; equality lists written before the attributes they assumed were added.","solutions":["Correct the name in the equality list to match an existing attribute exactly","If the attribute genuinely should participate in equality, declare it under attributes first","Remove stale entries for attributes that no longer exist"],"exampleFix":"# before\ntype MyApp::User = Object[{\n  attributes => { name => String, id => Integer },\n  equality => ['nam']          # attribute is 'name'\n}]\n\n# after\ntype MyApp::User = Object[{\n  attributes => { name => String, id => Integer },\n  equality => ['name']\n}]","handlingStrategy":"validation","validationCode":"# every equality entry must be an attribute of this type or a parent\nmembers = type.parent ? type.parent.members(true).merge(own_attrs) : own_attrs\nunknown = equality_list - members.keys\nraise \"equality references unknown attributes: #{unknown.inspect}\" unless unknown.empty?","typeGuard":null,"tryCatchPattern":"begin\n  Puppet::Pops::Types::PObjectType.new(name, init_hash)\nrescue Puppet::ParseError => e\n  raise unless e.message =~ /referencing non existent attribute/\n  raise  # e.message names the missing attribute; fix spelling or declare it\nend","preventionTips":["Keep equality lists next to the attributes block and update both together","Prefer default equality (omit the list) unless specific members must be excluded"],"tags":["puppet","pcore","object-type","equality","unknown-reference"],"backgroundTag":"unknown-attribute-reference","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}