puppetlabs/puppet · error · Puppet::ParseError
%{member} attempts to override %{label} without having overr
Error message
%{member} attempts to override %{label} without having override => true What it means
Puppet requires overriding an inherited Object type member to be explicit: the child member must be declared with 'override' => true. assert_can_be_overridden raises this Puppet::ParseError when a same-named inherited member exists but the redeclaration does not carry the flag — protection against silently changing a parent contract by accident.
Source
Thrown at lib/puppet/pops/types/p_object_type.rb:181
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
if @final && !(constant? && member.constant?)
raise Puppet::ParseError, _("%{member} attempts to override final %{label}") % { member: member.label, label: label }
end
unless member.override?
# TRANSLATOR 'override => true' is a puppet syntax and should not be translated
raise Puppet::ParseError, _("%{member} attempts to override %{label} without having override => true") % { member: member.label, label: label }
end
unless @type.assignable?(member.type)
raise Puppet::ParseError, _("%{member} attempts to override %{label} with a type that does not match") % { member: member.label, label: label }
end
member
end
def constant?
false
end
# @return [Boolean] `true` if this feature cannot be overridden
# @api public
def final?
@final
end
View on GitHub (pinned to e227c27540)
Solutions
- If the redeclaration is intentional, add 'override' => true to the child member's hash.
- If the name collision is accidental, rename the child's member.
- Audit the parent type's attribute list when a child mysteriously fails to compile.
Example fix
# before
type Sub = Object[{
'parent' => 'Base',
'attributes' => { 'size' => Integer } # Base already defines 'size'
}]
# after
type Sub = Object[{
'parent' => 'Base',
'attributes' => { 'size' => {'type' => Integer, 'override' => true} }
}] Defensive patterns
Strategy: validation
Validate before calling
# Ruby — when generating child types, set the flag automatically for redeclarations
if parent_members.key?(name)
entry = entry.merge('override' => true)
end Type guard
def needs_override_flag?(name, parent_members) parent_members.key?(name) end
Try / catch
begin
Puppet::Pops::Types::PObjectType.new(name, hash)
rescue Puppet::ParseError => e
raise CompileError, "redeclared inherited member without override => true: #{e.message}"
end Prevention
- When naming attributes, list the parent's members first and avoid collisions unless overriding deliberately.
- Code-generate child types with an override flag inserted for every inherited name.
When it happens
Trigger: Child Object type declares an attribute (or type parameter) with the same name as one inherited from its parent, without 'override' => true — e.g. parent has attribute 'name', child redeclares 'name' => String.
Common situations: Developers from mainstream OOP languages expecting implicit overriding; accidental name collisions with common attribute names ('name', 'id', 'version') that the parent already defines.
Related errors
- expected %{label} to override an inherited %{feature_type},
- %{member} attempts to override %{label}
- %{member} attempts to override final %{label}
- %{member} attempts to override %{label} with a type that doe
- %{label} of kind 'constant' cannot be combined with final =>
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/3717857a2018a934.
Report an issue: GitHub.