puppetlabs/puppet · error · Serialization::SerializationError
Initializer for class #{impl_class.name} parameter '#{ip}' d
Error message
Initializer for class #{impl_class.name} parameter '#{ip}' does not match any of the attributes of type #{name} What it means
Companion to the initializer arity check in parameter_info: when the Ruby implementation class's initialize parameter list is the right size but a parameter name matches none of the Object type's attributes, Puppet cannot map constructor arguments to attributes and raises Serialization::SerializationError naming the offending parameter.
Source
Thrown at lib/puppet/pops/types/p_object_type.rb:658
# assert that the protected name wasn't a real name (names can start with underscore)
n = r unless param_names.index(r).nil?
end
n
end
if init_param_names != param_names
if init_param_names.size < param_count || init_non_opt_count > param_count
raise Serialization::SerializationError, "Initializer for class #{impl_class.name} does not match the attributes of #{name}"
end
init_param_names = init_param_names[0, param_count] if init_param_names.size > param_count
unless init_param_names == param_names
# Reorder needed to match initialize method arguments
new_param_types = []
init_param_names.each do |ip|
index = param_names.index(ip)
if index.nil?
raise Serialization::SerializationError,
"Initializer for class #{impl_class.name} parameter '#{ip}' does not match any of the attributes of type #{name}"
end
new_param_types << param_types[index]
end
param_names = init_param_names
param_types = new_param_types
end
end
pic = [param_names.freeze, param_types.freeze, non_opt_types.size].freeze
@parameter_info[impl_class] = pic
pic
end
# @api private
def attr_reader_name(se)
if se.value_type.is_a?(PBooleanType) || se.value_type.is_a?(POptionalType) && se.value_type.type.is_a?(PBooleanType)
"#{se.name}?"View on GitHub (pinned to e227c27540)
Solutions
- Rename the initialize parameter to exactly match the declared attribute name
- If the name is correct in initialize, add or fix the attribute in the interface so the two agree
- Remove the stray parameter entirely if it corresponds to no attribute
Example fix
# before
type attributes: { x => Integer, y => Integer, z => Integer }
def initialize(x, y, w) # 'w' matches no attribute
...
end
# after
def initialize(x, y, z)
...
end Defensive patterns
Strategy: validation
Validate before calling
# assert every initialize parameter name is an attribute name
attr_names = type.attributes(true).keys
params = impl_class.instance_method(:initialize).parameters.map { |_, n| n.to_s }
unknown = params - attr_names
abort "initialize parameters not matching any attribute: #{unknown.inspect}" unless unknown.empty? Try / catch
begin type.create(*args) rescue Puppet::Pops::Serialization::SerializationError => e raise unless e.message =~ /parameter '.*' does not match any of the attributes/ # e.message names the offending parameter; fix the impl class signature raise end
Prevention
- Name initialize parameters exactly after the declared attributes
- Run a startup assertion comparing parameter names with attribute names (see validationCode)
- Rename attributes and initialize parameters together in one refactor
When it happens
Trigger: initialize has a parameter whose name is not an attribute of the type: a typo (w vs z), a renamed attribute still referenced by the old name in initialize, or an extra positional parameter with a default value that shadows no attribute.
Common situations: Renaming an attribute in the interface string while leaving the implementation class unchanged; hand-written implementation classes whose initialize uses different names than the declarative attributes; copy-paste between similar types.
Related errors
- Initializer for class #{impl_class.name} does not match the
- The attribute '%{name}' is reserved and cannot be used
- #{klass} does not respond to #{intern_multiple_method}; can
- #{instance.class} does not respond to #{render_method}; can
- %{klass} does not respond to %{method}; can not render multi
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/610256a9a10e5d73.
Report an issue: GitHub.