puppetlabs/puppet · error · Puppet::ParseError

expected %{label} to override an inherited %{feature_type},

Error message

expected %{label} to override an inherited %{feature_type}, but no such %{feature_type} was found

What it means

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.

Source

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

    # @param guard [RecursionGuard] guard against recursion. Only used by internal calls
    # @api public
    def accept(visitor, guard)
      annotatable_accept(visitor, guard)
      @type.accept(visitor, guard)
    end

    # Checks if the this _member_ overrides an inherited member, and if so, that this member is declared with override = true and that
    # the inherited member accepts to be overridden by this member.
    #
    # @param parent_members [Hash{String=>PAnnotatedMember}] the hash of inherited members
    # @return [PAnnotatedMember] this instance
    # @raises [Puppet::ParseError] if the assertion fails
    # @api private
    def assert_override(parent_members)
      parent_member = parent_members[@name]
      if parent_member.nil?
        if @override
          raise Puppet::ParseError, _("expected %{label} to override an inherited %{feature_type}, but no such %{feature_type} was found") %
                                    { label: label, feature_type: feature_type }
        end
        self
      else
        parent_member.assert_can_be_overridden(self)
      end
    end

    # Checks if the given _member_ can override this member.
    #
    # @param member [PAnnotatedMember] the overriding member
    # @return [PAnnotatedMember] its argument
    # @raises [Puppet::ParseError] if the assertion fails
    # @api private
    def assert_can_be_overridden(member)
      unless instance_of?(member.class)
        raise Puppet::ParseError, _("%{member} attempts to override %{label}") % { member: member.label, label: label }
      end

View on GitHub (pinned to e227c27540)

Solutions

  1. Remove 'override' => true from the member — plain new members must not claim to override.
  2. If an override was intended, add (or restore) a member with that exact name to the parent type.
  3. Check spelling/casing of both the parent reference and the member name; the lookup is an exact string match.

Example fix

# before
type Sub = Object[{
  'parent' => 'Base',
  'attributes' => { 'extra' => { 'type' => Integer, 'override' => true } }
}]

# after
type Sub = Object[{
  'parent' => 'Base',
  'attributes' => { 'extra' => Integer }   # new member, no override claim
}]
Defensive patterns

Strategy: validation

Validate before calling

# Ruby — when composing child types programmatically, check the parent first
parent_attrs = parent.nil? ? {} : parent.attributes
child_attrs.each do |name, a|
  fail("#{name} claims override but #{parent&.name} has no such member") if a.override? && !parent_attrs.key?(name)
end

Type guard

def override_claim_valid?(member, parent_members)
  !member.override? || parent_members.key?(member.name)
end

Try / catch

begin
  Puppet::Pops::Types::PObjectType.new(name, init_hash)
rescue Puppet::ParseError => e
  raise CompileError, "object type #{name} invalid: #{e.message}" # surface at type-build time
end

Prevention

When it happens

Trigger: type Sub = Object[{'parent' => 'Base', 'attributes' => {'extra' => {'type' => Integer, 'override' => true}}}] where Base has no attribute or type parameter named 'extra'.

Common situations: 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.

Related errors


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