puppetlabs/puppet · error · Puppet::ParseError

reference to unresolved type '%{name}'

Error message

reference to unresolved type '%{name}'

What it means

While resolving an Object type, Puppet resolves the declared parent through the loader. If the loader can only produce a PTypeReferenceType - an unresolved reference to a type name - the parent cannot be used, and Puppet::ParseError 'reference to unresolved type' is raised with the unresolved type string.

Source

Thrown at lib/puppet/pops/types/p_object_type.rb:705

  def _pcore_init_from_hash(init_hash)
    TypeAsserter.assert_instance_of('object initializer', TYPE_OBJECT_I12N, init_hash)
    @type_parameters = EMPTY_HASH
    @attributes = EMPTY_HASH
    @functions = EMPTY_HASH

    # Name given to the loader have higher precedence than a name declared in the type
    @name ||= init_hash[KEY_NAME]
    @name.freeze unless @name.nil?

    @parent = init_hash[KEY_PARENT]

    parent_members = EMPTY_HASH
    parent_type_params = EMPTY_HASH
    parent_object_type = nil
    unless @parent.nil?
      check_self_recursion(self)
      rp = resolved_parent
      raise Puppet::ParseError, _("reference to unresolved type '%{name}'") % { :name => rp.type_string } if rp.is_a?(PTypeReferenceType)

      if rp.is_a?(PObjectType)
        parent_object_type = rp
        parent_members = rp.members(true)
        parent_type_params = rp.type_parameters(true)
      end
    end

    type_parameters = init_hash[KEY_TYPE_PARAMETERS]
    unless type_parameters.nil? || type_parameters.empty?
      @type_parameters = {}
      type_parameters.each do |key, param_spec|
        param_value = :undef
        if param_spec.is_a?(Hash)
          param_type = param_spec[KEY_TYPE]
          param_value = param_spec[KEY_VALUE] if param_spec.include?(KEY_VALUE)
        else
          param_type = TypeAsserter.assert_instance_of(nil, PTypeType::DEFAULT, param_spec) { "type_parameter #{label}[#{key}]" }

View on GitHub (pinned to e227c27540)

Solutions

  1. Verify the parent type name spelling and capitalization exactly matches its definition
  2. Ensure the module defining the parent is present on the modulepath and listed in metadata.json dependencies
  3. If the parent is a Puppet 3.x or core type, use the correct core name; only Object types may be parents
  4. Check that both types share a loadable name authority (same module namespace or explicit name_authority)

Example fix

# before
type MyApp::Child = Object[{
  parent => 'MyApp::Parrent',   # typo, cannot be resolved
  attributes => { extra => String }
}]

# after
type MyApp::Child = Object[{
  parent => 'MyApp::Parent',
  attributes => { extra => String }
}]
Defensive patterns

Strategy: validation

Validate before calling

# resolve the parent name through the same loader before defining the child
resolved = Puppet::Pops::Types::TypeParser.singleton.parse('MyApp::Parent', loader)
if resolved.is_a?(Puppet::Pops::Types::PTypeReferenceType)
  raise "parent type cannot be resolved: #{resolved.type_string} - check module dependencies"
end

Type guard

def resolvable_parent?(name, loader)
  t = Puppet::Pops::Types::TypeParser.singleton.parse(name, loader)
  !t.is_a?(Puppet::Pops::Types::PTypeReferenceType)
end

Try / catch

begin
  Puppet::Pops::Types::PObjectType.new(name, init_hash)
rescue Puppet::ParseError => e
  raise unless e.message =~ /reference to unresolved type/
  # e.message contains the unresolved type string; verify module presence and spelling
  raise
end

Prevention

When it happens

Trigger: A type declaration like type MyApp::Child = Object[{ parent => 'Does::NotExist', ... }], or a parent type defined in a module that is not installed, not declared as a dependency, or not yet loaded at resolution time. Name-authority mismatches (fully qualified name resolving to a different authority) also produce an unresolved reference.

Common situations: Typo or wrong capitalization in the parent name; parent type lives in another module missing from metadata.json dependencies; module extracted to a different name; Puppet 4 type alias referencing a type from an unavailable environment.

Related errors


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