{"record":{"id":"e3bd42054482895c","repo":"puppetlabs/puppet","slug":"the-code-loaded-from-source-ref-produced-resour","errorCode":null,"errorMessage":"The code loaded from %{source_ref} produced resource type with the wrong name, expected '%{expected}', actual '%{actual}'","messagePattern":"The code loaded from %(.+?) produced resource type with the wrong name, expected '%(.+?)', actual '%(.+?)'","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb","lineNumber":69,"sourceCode":"      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 }\n    end\n\n    unless statements.size == 1\n      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 }\n    end\n\n    closure_scope = Puppet.lookup(:global_scope) { {} }\n    resource_type_impl = parser.evaluate(closure_scope, model)\n\n    unless resource_type_impl.is_a?(Puppet::Pops::Resource::ResourceTypeImpl)\n      got = resource_type.class\n      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 }\n    end\n\n    unless resource_type_impl.name == typed_name.name\n      expected = typed_name.name\n      actual = resource_type_impl.name\n      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 }\n    end\n\n    # Adapt the resource type definition with loader - this is used from logic contained in it body to find the\n    # loader to use when making calls to the new function API. Such logic have a hard time finding the closure (where\n    # the loader is known - hence this mechanism\n    Adapters::LoaderAdapter.adapt(resource_type_impl).loader_name = loader.loader_name\n    resource_type_impl\n  end\nend\nend\nend\n","sourceCodeStart":51,"sourceCodeEnd":81,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb#L51-L81","documentation":"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.","triggerScenarios":"`resource_type_impl.name != typed_name.name`: e.g. types/foo.pp contains Resource::ResourceTypeImpl.new('mod::bar', ...) while the loader binds mod::foo.","commonSituations":"Renaming the file or the name string without updating the other; copy-pasted type files; missing the module namespace segment in the name string.","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"],"exampleFix":"# before - modules/mymod/types_greeting/thing.pp\nResource::ResourceTypeImpl.new('mymod::widget', ...)\n\n# after\nResource::ResourceTypeImpl.new('mymod::thing', ...)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"begin\n  impl = loader.load_typed(typed_name)\nrescue ArgumentError => e\n  raise unless e.message.include?('wrong name')\n  warn \"type name mismatch: #{e.message}\"\nend","preventionTips":["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"],"tags":["puppet","resource-type","naming","loader"],"backgroundTag":"puppet-definition-name-mismatch","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}