puppetlabs/puppet · error · Puppet::Error

Unable to create an instance of #

Error message

Unable to create an instance of #{type.name}. No mapping exists to runtime object

What it means

The Ruby generator is emitting implementation registrations for object types and the implementation registry has no Ruby class/module mapping for one of the types; its runtime name cannot be determined.

Solutions

  1. Register an implementation for the type with Puppet::Pops::Pcore or the implementation registry
  2. Ensure the type's implementation reference resolves before code generation
  3. Annotate the Object type with the Ruby runtime it should map to
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/puppet/pops/types/ruby_generator.rb:164 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/ce48d8cbcc2ab52c. Report an issue: GitHub.

Appendix: source

Thrown at lib/puppet/pops/types/ruby_generator.rb:164

    end

    # Emit registration of contained types
    unless class_names.empty?
      bld << "Puppet::Pops::Pcore.register_implementations([\n"
      class_names.each { |class_name| bld << '  ' << class_name << ",\n" }
      bld.chomp!(",\n")
      bld << "])\n\n"
    end
    bld.chomp!("\n")

    common_prefix.size.times { bld << "end\n" }
  end

  def implementation_names(object_types)
    object_types.map do |type|
      ir = Loaders.implementation_registry
      impl_name = ir.module_name_for_type(type)
      raise Puppet::Error, "Unable to create an instance of #{type.name}. No mapping exists to runtime object" if impl_name.nil?

      impl_name
    end
  end

  def class_definition(obj, namespace_segments, bld, class_name, *impl_subst)
    module_segments = remove_common_namespace(namespace_segments, class_name)
    leaf_name = module_segments.pop
    module_segments.each { |segment| bld << 'module ' << segment << "\n" }
    scoped_class_definition(obj, leaf_name, bld, class_name, *impl_subst)
    module_segments.size.times { bld << "end\n" }
    module_segments << leaf_name
    module_segments.join(TypeFormatter::NAME_SEGMENT_SEPARATOR)
  end

  def scoped_class_definition(obj, leaf_name, bld, class_name, *impl_subst)
    bld << 'class ' << leaf_name
    segments = class_name.split(TypeFormatter::NAME_SEGMENT_SEPARATOR)

View on GitHub (pinned to e227c27540)