{"record":{"id":"5554ecc28463eff5","repo":"puppetlabs/puppet","slug":"expected-label-to-override-an-inherited-featu","errorCode":null,"errorMessage":"expected %{label} to override an inherited %{feature_type}, but no such %{feature_type} was found","messagePattern":"expected %(.+?) to override an inherited %(.+?), but no such %(.+?) was found","errorType":"exception","errorClass":"Puppet::ParseError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/p_object_type.rb","lineNumber":157,"sourceCode":"    # @param guard [RecursionGuard] guard against recursion. Only used by internal calls\n    # @api public\n    def accept(visitor, guard)\n      annotatable_accept(visitor, guard)\n      @type.accept(visitor, guard)\n    end\n\n    # Checks if the this _member_ overrides an inherited member, and if so, that this member is declared with override = true and that\n    # the inherited member accepts to be overridden by this member.\n    #\n    # @param parent_members [Hash{String=>PAnnotatedMember}] the hash of inherited members\n    # @return [PAnnotatedMember] this instance\n    # @raises [Puppet::ParseError] if the assertion fails\n    # @api private\n    def assert_override(parent_members)\n      parent_member = parent_members[@name]\n      if parent_member.nil?\n        if @override\n          raise Puppet::ParseError, _(\"expected %{label} to override an inherited %{feature_type}, but no such %{feature_type} was found\") %\n                                    { label: label, feature_type: feature_type }\n        end\n        self\n      else\n        parent_member.assert_can_be_overridden(self)\n      end\n    end\n\n    # Checks if the given _member_ can override this member.\n    #\n    # @param member [PAnnotatedMember] the overriding member\n    # @return [PAnnotatedMember] its argument\n    # @raises [Puppet::ParseError] if the assertion fails\n    # @api private\n    def assert_can_be_overridden(member)\n      unless instance_of?(member.class)\n        raise Puppet::ParseError, _(\"%{member} attempts to override %{label}\") % { member: member.label, label: label }\n      end","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/p_object_type.rb#L139-L175","documentation":"In Puppet Object types, a member declared with override => true asserts that it actually overrides an inherited member. assert_override looks the member name up in the parent's members; if the parent defines no such member, the override claim is false and a Puppet::ParseError is raised at type-definition time.","triggerScenarios":"type Sub = Object[{'parent' => 'Base', 'attributes' => {'extra' => {'type' => Integer, 'override' => true}}}] where Base has no attribute or type parameter named 'extra'.","commonSituations":"Renaming or removing a parent attribute while children keep override => true; copy-pasting an overridden attribute block into a type with a different (or no) parent; adding override 'for safety' where no inheritance exists.","solutions":["Remove 'override' => true from the member — plain new members must not claim to override.","If an override was intended, add (or restore) a member with that exact name to the parent type.","Check spelling/casing of both the parent reference and the member name; the lookup is an exact string match."],"exampleFix":"# before\ntype Sub = Object[{\n  'parent' => 'Base',\n  'attributes' => { 'extra' => { 'type' => Integer, 'override' => true } }\n}]\n\n# after\ntype Sub = Object[{\n  'parent' => 'Base',\n  'attributes' => { 'extra' => Integer }   # new member, no override claim\n}]","handlingStrategy":"validation","validationCode":"# Ruby — when composing child types programmatically, check the parent first\nparent_attrs = parent.nil? ? {} : parent.attributes\nchild_attrs.each do |name, a|\n  fail(\"#{name} claims override but #{parent&.name} has no such member\") if a.override? && !parent_attrs.key?(name)\nend","typeGuard":"def override_claim_valid?(member, parent_members)\n  !member.override? || parent_members.key?(member.name)\nend","tryCatchPattern":"begin\n  Puppet::Pops::Types::PObjectType.new(name, init_hash)\nrescue Puppet::ParseError => e\n  raise CompileError, \"object type #{name} invalid: #{e.message}\" # surface at type-build time\nend","preventionTips":["Only write 'override' => true immediately after confirming the member exists in the parent.","When renaming a parent attribute, grep child types for stale override declarations."],"tags":["puppet","object-type","inheritance","override","type-declaration"],"backgroundTag":"invalid-override-declaration","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}