puppetlabs/puppet · error · ArgumentError
The code loaded from %{source_ref} produced resource type wi
Error message
The code loaded from %{source_ref} produced resource type with the wrong name, expected '%{expected}', actual '%{actual}' What it means
Raised by PuppetResourceTypeImplInstantiator when the evaluated ResourceTypeImpl's name differs from the typed name derived from the file path. The name string passed to Resource::ResourceTypeImpl.new must equal the module::name the loader resolved, or load fails.
Source
Thrown at lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb:69
raise ArgumentError, _("The code loaded from %{source_ref} does not create the resource type '%{type_name}' - no call to %{rname}.new found.") % { source_ref: source_ref, type_name: typed_name.name, rname: rname }
end
unless statements.size == 1
raise ArgumentError, _("The code loaded from %{source_ref} must contain only the creation of resource type '%{type_name}' - it has additional logic.") % { source_ref: source_ref, type_name: typed_name.name }
end
closure_scope = Puppet.lookup(:global_scope) { {} }
resource_type_impl = parser.evaluate(closure_scope, model)
unless resource_type_impl.is_a?(Puppet::Pops::Resource::ResourceTypeImpl)
got = resource_type.class
raise ArgumentError, _("The code loaded from %{source_ref} does not define the resource type '%{type_name}' - got '%{got}'.") % { source_ref: source_ref, type_name: typed_name.name, got: got }
end
unless resource_type_impl.name == typed_name.name
expected = typed_name.name
actual = resource_type_impl.name
raise ArgumentError, _("The code loaded from %{source_ref} produced resource type with the wrong name, expected '%{expected}', actual '%{actual}'") % { source_ref: source_ref, expected: expected, actual: actual }
end
# Adapt the resource type definition with loader - this is used from logic contained in it body to find the
# loader to use when making calls to the new function API. Such logic have a hard time finding the closure (where
# the loader is known - hence this mechanism
Adapters::LoaderAdapter.adapt(resource_type_impl).loader_name = loader.loader_name
resource_type_impl
end
end
end
end
View on GitHub (pinned to e227c27540)
Solutions
- Set the constructor's name argument to the exact module::path-derived name
- Rename the file to match the constructor name if that name is the desired one
- Check for typos and missing namespace segments in both file name and name string
Example fix
# before - modules/mymod/types_greeting/thing.pp
Resource::ResourceTypeImpl.new('mymod::widget', ...)
# after
Resource::ResourceTypeImpl.new('mymod::thing', ...) Defensive patterns
Strategy: try-catch
Try / catch
begin
impl = loader.load_typed(typed_name)
rescue ArgumentError => e
raise unless e.message.include?('wrong name')
warn "type name mismatch: #{e.message}"
end Prevention
- Generate the constructor name from the file path, not by hand
- Rename file and name string together
- Include the full module namespace in the name string
When it happens
Trigger: `resource_type_impl.name != typed_name.name`: e.g. types/foo.pp contains Resource::ResourceTypeImpl.new('mod::bar', ...) while the loader binds mod::foo.
Common situations: Renaming the file or the name string without updating the other; copy-pasted type files; missing the module namespace segment in the name string.
Related errors
- The code loaded from %{source_ref} produced plan with the wr
- The code loaded from %{source_ref} does not create the resou
- The code loaded from %{source_ref} does not create the resou
- The code loaded from %{source_ref} must contain only the cre
- The code loaded from %{source_ref} does not define the resou
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/e3bd42054482895c.
Report an issue: GitHub.