{"record":{"id":"14af07f27ad5b0b4","repo":"puppetlabs/puppet","slug":"could-not-find-resource-type-name","errorCode":null,"errorMessage":"Could not find resource type '%{name}'","messagePattern":"Could not find resource type '%(.+?)'","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/type/resources.rb","lineNumber":18,"sourceCode":"# frozen_string_literal: true\n\nrequire_relative '../../puppet'\nrequire_relative '../../puppet/parameter/boolean'\n\nPuppet::Type.newtype(:resources) do\n  @doc = \"This is a metatype that can manage other resource types.  Any\n    metaparams specified here will be passed on to any generated resources,\n    so you can purge unmanaged resources but set `noop` to true so the\n    purging is only logged and does not actually happen.\"\n\n  apply_to_all\n\n  newparam(:name) do\n    desc \"The name of the type to be managed.\"\n\n    validate do |name|\n      raise ArgumentError, _(\"Could not find resource type '%{name}'\") % { name: name } unless Puppet::Type.type(name)\n    end\n\n    munge(&:to_s)\n  end\n\n  newparam(:purge, :boolean => true, :parent => Puppet::Parameter::Boolean) do\n    desc \"Whether to purge unmanaged resources.  When set to `true`, this will\n      delete any resource that is not specified in your configuration and is not\n      autorequired by any managed resources. **Note:** The `ssh_authorized_key`\n      resource type can't be purged this way; instead, see the `purge_ssh_keys`\n      attribute of the `user` type.\"\n\n    defaultto :false\n\n    validate do |value|\n      if munge(value)\n        unless @resource.resource_type.respond_to?(:instances)\n          raise ArgumentError, _(\"Purging resources of type %{res_type} is not supported, since they cannot be queried from the system\") % { res_type: @resource[:name] }","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/type/resources.rb#L1-L36","documentation":"The `resources` metatype (used to purge or inspect all instances of a type) validates its namevar against the type registry: `Puppet::Type.type(name)` must resolve (lib/puppet/type/resources.rb:18). Unknown or misspelled type names — including custom types whose Ruby lib was never loaded into the compiling process — raise ArgumentError \"Could not find resource type\".","triggerScenarios":"`resources { 'users': purge => true }` (plural typo; the type is `user`); referencing a custom type from a module not present in the environment; running `puppet apply` without the module on the modulepath; wrong capitalization of the type name.","commonSituations":"Typos like users/user, pkgs/package, ssh_authorized_keys (plural); module refactors that removed a type while manifests still purge it; agents/compilers missing pluginsynced custom type files after environment changes.","solutions":["Correct the name to the exact, singular, lowercase type name (user, package, group, mount)","If it is a custom type, ensure the module is in the environment and pluginsync delivered lib/puppet/type/*.rb to the agent (run the agent once, check the plugin destination)","For puppet apply, pass --modulepath so the custom type is autoloaded before compilation"],"exampleFix":"# before\nresources { 'ssh_authorized_keys':\n  purge => true,\n}\n\n# after\nresources { 'ssh_authorized_key':\n  purge => true,\n}","handlingStrategy":"type-guard","validationCode":"# fail fast in generated manifests\nunless Puppet::Type.type(type_name.to_sym)\n  raise ArgumentError, \"resources: unknown type '#{type_name}'\"\nend","typeGuard":"def known_type?(name)\n  !Puppet::Type.type(name.to_s.to_sym).nil?\nend","tryCatchPattern":"begin\n  Puppet::Type.type(:resources).new(name: 'users', purge: true)\nrescue ArgumentError => e\n  raise unless e.message.include?('Could not find resource type')\n  # fix the name or load the module providing the type\nend","preventionTips":["Run `puppet parser validate` and catalog-compile tests in CI","Use singular lowercase type names in resources declarations","After deleting a module, grep for `resources {` referencing its types"],"tags":["puppet","metatype","unknown-type","pluginsync","typo"],"backgroundTag":"unknown-resource-type","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}