{"record":{"id":"adbdaee14b3822cf","repo":"puppetlabs/puppet","slug":"the-code-loaded-from-source-ref-does-not-create","errorCode":null,"errorMessage":"The code loaded from %{source_ref} does not create the resource type '%{type_name}' - it is empty","messagePattern":"The code loaded from %(.+?) does not create the resource type '%(.+?)' - it is empty","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb","lineNumber":35,"sourceCode":"  # @return [Puppet::Pops::ResourceTypeImpl] - an instantiated ResourceTypeImpl\n  #\n  def self.create(loader, typed_name, source_ref, pp_code_string)\n    parser = Parser::EvaluatingParser.new()\n\n    # parse and validate\n    model = parser.parse_string(pp_code_string, source_ref)\n    statements = if model.is_a?(Model::Program)\n                   if model.body.is_a?(Model::BlockExpression)\n                     model.body.statements\n                   else\n                     [model.body]\n                   end\n                 else\n                   EMPTY_ARRAY\n                 end\n    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","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb#L17-L53","documentation":"Raised by PuppetResourceTypeImplInstantiator when a Puppet-language resource type definition file contains no statements at all after parsing (Nops are rejected). The instantiator expects code that constructs a resource type via Resource::ResourceTypeImpl.new, so an empty or comments-only file fails with this ArgumentError at load.","triggerScenarios":"Loading a resource type .pp file where `statements` (Program body statements with Model::Nop entries rejected) is empty -- an empty file, whitespace/comments only, or a body that parsed entirely to Nops.","commonSituations":"Scaffolding tools creating placeholder files; deleting the body but leaving the file; merge conflicts resolved to empty content.","solutions":["Populate the file with a single Resource::ResourceTypeImpl.new(...) call","Delete the file if the resource type is not intended","Confirm via source_ref that the loader is pointed at the intended file"],"exampleFix":"# before - modules/mymod/types_greeting/thing.pp (empty file)\n\n# after\nResource::ResourceTypeImpl.new('mymod::thing',\n  is_capability: false,\n  attributes: {\n    message: { type: String, default: 'hello', kind: 'parameter' }\n  }\n)","handlingStrategy":"validation","validationCode":"model = Puppet::Pops::Parser::Parser.new.parse_string(code, source_ref)\nstmts = (model.is_a?(Puppet::Pops::Model::Program) ? [model.body].flatten : []).reject { |s| s.is_a?(Puppet::Pops::Model::Nop) }\n# approximate: a Program body BlockExpression's statements must be non-empty\nraise ArgumentError, \"#{source_ref} is empty\" if stmts.compact.empty?","typeGuard":null,"tryCatchPattern":"begin\n  loader.load_typed(typed_name)\nrescue ArgumentError => e\n  raise unless e.message.include?('it is empty')\n  warn \"empty resource type file: #{e.message}\"\nend","preventionTips":["Do not create placeholder files for resource types","Delete rather than empty a retired resource type file","Check scaffolding output for zero-content files in CI"],"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"}