puppetlabs/puppet · error · Puppet::Pops::Serialization::SerializationError

Missing default value for

Error message

Missing default value for %{type_name}[%{name}]

What it means

ObjectReader#read: an optional attribute omitted from the stream has no default value registered in the type, so the object cannot be fully constructed.

Solutions

  1. Define a default value for the attribute in the object type
  2. Serialize all attributes explicitly
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/puppet/pops/serialization/object.rb:29 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at lib/puppet/pops/serialization/object.rb:29

  include InstanceReader

  def read(type, impl_class, value_count, deserializer)
    (names, types, required_count) = type.parameter_info(impl_class)
    max = names.size
    unless value_count >= required_count && value_count <= max
      raise Serialization::SerializationError, _("Feature count mismatch for %{value0}. Expected %{required_count} - %{max}, actual %{value_count}") % { value0: impl_class.name, required_count: required_count, max: max, value_count: value_count }
    end

    # Deserializer must know about this instance before we read its attributes
    val = deserializer.remember(impl_class.allocate)
    args = Array.new(value_count) { deserializer.read }
    types.each_with_index do |ptype, index|
      if index < args.size
        arg = args[index]
        Types::TypeAsserter.assert_instance_of(nil, ptype, arg) { "#{type.name}[#{names[index]}]" } unless arg == :default
      else
        attr = type[names[index]]
        raise Serialization::SerializationError, _("Missing default value for %{type_name}[%{name}]") % { type_name: type.name, name: names[index] } unless attr && attr.value?

        args << attr.value
      end
    end
    val.send(:initialize, *args)
    val
  end

  INSTANCE = ObjectReader.new
end

# Instance writer for objects that implement {Types::PuppetObject}
# @api private
class ObjectWriter
  include InstanceWriter

  def write(type, value, serializer)
    impl_class = value.class

View on GitHub (pinned to e227c27540)