puppetlabs/puppet · error · SerializationError

Cannot create a from a

Error message

Cannot create a %{type_name} from a %{arg_class}

What it means

pcore_type_hash_to_value: object construction via the ObjectArrayBuilder received a value whose class does not match what the type expects for that attribute position.

Solutions

  1. Fix the serialized data so attribute values match the declared attribute types
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at lib/puppet/pops/serialization/from_data_converter.rb:225 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/a27714c192ee979b. Report an issue: GitHub.

Appendix: source

Thrown at lib/puppet/pops/serialization/from_data_converter.rb:225

      with_value(builder, &block) if block_given?
      builder.resolve
    end

    def pcore_type_hash_to_value(pcore_type, value)
      case value
      when Hash
        # Complex object
        if value.empty?
          build(pcore_type.create)
        elsif pcore_type.implementation_class.respond_to?(:_pcore_init_from_hash)
          build_object(ObjectHashBuilder.new(pcore_type.allocate)) { value.each_pair { |key, elem| with(key) { convert(elem) } } }
        else
          build_object(ObjectArrayBuilder.new(pcore_type.allocate)) { value.each_pair { |key, elem| with(key) { convert(elem) } } }
        end
      when String
        build(pcore_type.create(value))
      else
        raise SerializationError, _('Cannot create a %{type_name} from a %{arg_class}') %
                                  { :type_name => pcore_type.name, :arg_class => value.class.name }
      end
    end
  end
end
end

View on GitHub (pinned to e227c27540)