{"record":{"id":"f4508feb67fbc899","repo":"puppetlabs/puppet","slug":"the-code-loaded-from-source-ref-does-not-create-f4508f","errorCode":null,"errorMessage":"The code loaded from %{source_ref} does not create the resource type '%{type_name}' - no call to %{rname}.new found.","messagePattern":"The code loaded from %(.+?) does not create the resource type '%(.+?)' - no call to %(.+?)\\.new found\\.","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb","lineNumber":51,"sourceCode":"    statements = statements.reject { |s| s.is_a?(Model::Nop) }\n    if statements.empty?\n      raise ArgumentError, _(\"The code loaded from %{source_ref} does not create the resource type '%{type_name}' - it is empty\") % { source_ref: source_ref, type_name: typed_name.name }\n    end\n\n    rname = Resource::ResourceTypeImpl._pcore_type.name\n    unless statements.find do |s|\n      if s.is_a?(Model::CallMethodExpression)\n        functor_expr = s.functor_expr\n        functor_expr.is_a?(Model::NamedAccessExpression) &&\n        functor_expr.left_expr.is_a?(Model::QualifiedReference) &&\n        functor_expr.left_expr.cased_value == rname &&\n        functor_expr.right_expr.is_a?(Model::QualifiedName) &&\n        functor_expr.right_expr.value == 'new'\n      else\n        false\n      end\n    end\n      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 }","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb#L33-L69","documentation":"Raised by PuppetResourceTypeImplInstantiator when the file has statements but none is a call to Resource::ResourceTypeImpl.new. The loader statically matches a CallMethodExpression whose functor is the QualifiedReference named by `Resource::ResourceTypeImpl._pcore_type.name` with selector 'new'; any other content (class bodies, function definitions, plain expressions) fails here.","triggerScenarios":"`statements.find` returns nil: the file contains no `Resource::ResourceTypeImpl.new(...)` call -- e.g. a class definition, a data type alias (`type X = ...`), or other Puppet code placed where a resource type implementation is loaded from.","commonSituations":"Putting an old-style custom type or a data type alias in the path the resource-type loader scans; partially migrated files; misunderstanding which Puppet feature uses this file format.","solutions":["Replace the file content with a single Resource::ResourceTypeImpl.new('<module>::<name>', ...) call","If you meant a data type alias, use the alias syntax in the module's type-alias location supported by your Puppet version","Follow the Puppet resource-type-in-language docs for the exact constructor shape"],"exampleFix":"# before - resource type file containing a class\nclass mymod::greeting {\n  notify { 'hello': }\n}\n\n# after\nResource::ResourceTypeImpl.new('mymod::greeting',\n  is_capability: false,\n  attributes: {\n    message: { type: String, default: 'hello', kind: 'parameter' }\n  }\n)","handlingStrategy":"validation","validationCode":"rname = Puppet::Pops::Resource::ResourceTypeImpl._pcore_type.name\nhas_ctor = statements.any? do |s|\n  next false unless s.is_a?(Puppet::Pops::Model::CallMethodExpression)\n  f = s.functor_expr\n  f.is_a?(Puppet::Pops::Model::NamedAccessExpression) &&\n    f.left_expr.is_a?(Puppet::Pops::Model::QualifiedReference) &&\n    f.left_expr.cased_value == rname &&\n    f.right_expr.is_a?(Puppet::Pops::Model::QualifiedName) &&\n    f.right_expr.value == 'new'\nend\nraise ArgumentError, \"missing #{rname}.new call\" unless has_ctor","typeGuard":null,"tryCatchPattern":"begin\n  loader.load_typed(typed_name)\nrescue ArgumentError => e\n  raise unless e.message.include?('.new found')\n  warn \"file is not a resource type definition: #{e.message}\"\nend","preventionTips":["Start resource type files from a verified Resource::ResourceTypeImpl.new template","Keep data type aliases out of the resource type path","Validate the file statically after generating it"],"tags":["puppet","resource-type","loader","puppet-language"],"backgroundTag":"puppet-resource-type-load-validation","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}