{"record":{"id":"6177e7b1b7d35904","repo":"puppetlabs/puppet","slug":"unknown-resource-type-type-6177e7","errorCode":null,"errorMessage":"Unknown resource type %{type}","messagePattern":"Unknown resource type %(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/resource/catalog.rb","lineNumber":293,"sourceCode":"    @resource_table.values.each(&:remove) if remove_resources\n    @resource_table.clear\n    @resources = []\n\n    if @relationship_graph\n      @relationship_graph.clear\n      @relationship_graph = nil\n    end\n  end\n\n  def classes\n    @classes.dup\n  end\n\n  # Create a new resource and register it in the catalog.\n  def create_resource(type, options)\n    klass = Puppet::Type.type(type)\n    unless klass\n      raise ArgumentError, _(\"Unknown resource type %{type}\") % { type: type }\n    end\n\n    resource = klass.new(options)\n    return unless resource\n\n    add_resource(resource)\n    resource\n  end\n\n  # Make sure all of our resources are \"finished\".\n  def finalize\n    make_default_resources\n\n    @resource_table.values.each(&:finish)\n\n    write_graph(:resources)\n  end\n","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/resource/catalog.rb#L275-L311","documentation":"Puppet::Resource::Catalog#create_resource first resolves the type via Puppet::Type.type(type); if that returns nil — no native type of that name is registered and no custom type could be autoloaded — it raises ArgumentError. Native types (file, service, package...) are always registered; custom types must be loadable from a module's lib/puppet/type directory.","triggerScenarios":"Calling catalog.create_resource('fil', options) (typo); referencing a custom type (e.g. 'myapp_conf') whose module is absent from the modulepath, not pluginsynced to the node, or whose lib/puppet/type/myapp_conf.rb raises on load; passing a class name like 'Class' instead of a manageable type; building a catalog before the environment/autoloader is initialized.","commonSituations":"Agent node missing a module that exists only on the server (pluginsync disabled or module not in environment); typo in generated manifests; scripts that assemble catalogs programmatically without requiring the module first; module renamed but generated code still uses the old type name.","solutions":["Verify the exact type name with `puppet resource --types` (or Puppet::Type.type(:name).inspect) and fix the spelling.","Ensure the module providing lib/puppet/type/<name>.rb is in the environment's modulepath and pluginsynced to the node.","Preload the type before use (require the file or reference Puppet::Type.type(:name)) and rescue/inspect load errors from the autoloader.","If the type genuinely does not exist, replace it with a composition of native types (file, exec, service)."],"exampleFix":"# before\ncatalog.create_resource('myservice', ensure: 'running')\n\n# after\ntype = Puppet::Type.type(:myservice)\nraise ArgumentError, 'myservice type not loadable; is its module on the modulepath?' unless type\ncatalog.create_resource(:myservice, ensure: 'running')","handlingStrategy":"validation","validationCode":"unless Puppet::Type.type(type)\n  raise ArgumentError, \"type #{type.inspect} not registered; check spelling and that its module is on the modulepath\"\nend\ncatalog.create_resource(type, options)","typeGuard":"loadable_type = ->(t) { !Puppet::Type.type(t).nil? }","tryCatchPattern":"begin\n  catalog.create_resource(type, options)\nrescue ArgumentError => e\n  raise unless e.message.include?('Unknown resource type')\n  # log available types to help diagnosis\n  Puppet.debug(Puppet::Type.alltypes.map(&:name).join(','))\n  raise\nend","preventionTips":["Verify type names against `puppet resource --types` before generating code","Ensure modules with custom types are deployed and pluginsynced on every node that compiles or applies the catalog","Preload custom types (require or Puppet::Type.type(:x)) in scripts that build catalogs outside an agent run"],"tags":["puppet","resource-type","autoloading","pluginsync","argumenterror"],"backgroundTag":"unknown-resource-type","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}