{"record":{"id":"f5fcb6537bc58bb7","repo":"puppetlabs/puppet","slug":"purging-resources-of-type-res-type-is-not-suppo","errorCode":null,"errorMessage":"Purging resources of type %{res_type} is not supported, since they cannot be queried from the system","messagePattern":"Purging resources of type %(.+?) is not supported, since they cannot be queried from the system","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/type/resources.rb","lineNumber":36,"sourceCode":"      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] }\n        end\n        raise ArgumentError, _(\"Purging is only supported on types that accept 'ensure'\") unless @resource.resource_type.validproperty?(:ensure)\n      end\n    end\n  end\n\n  newparam(:unless_system_user) do\n    desc \"This keeps system users from being purged.  By default, it\n      does not purge users whose UIDs are less than the minimum UID for the system (typically 500 or 1000), but you can specify\n      a different UID as the inclusive limit.\"\n\n    newvalues(:true, :false, /^\\d+$/)\n\n    munge do |value|\n      case value\n      when /^\\d+/\n        Integer(value)\n      when :true, true","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/type/resources.rb#L18-L54","documentation":"`resources { <type>: purge => true }` can only purge types that can enumerate themselves: the type class must respond to `.instances` (lib/puppet/type/resources.rb:36), because purging diffs the catalog against the system state. Types with no self-query mechanism raise ArgumentError \"Purging resources of type ... is not supported\".","triggerScenarios":"`resources { 'exec': purge => true }` (exec cannot be enumerated); purging any custom type whose author only defined properties/params without `def self.instances`; purging built-in meta-only types.","commonSituations":"Blanket 'purge everything unmanaged' profiles looped over many types; custom types written without instances(); trying to purge ssh_authorized_key via resources instead of the user type's purge_ssh_keys.","solutions":["Remove `purge` (or set it false) for that type and manage its instances explicitly","For custom types, implement `def self.instances` returning one resource per system instance","For ssh_authorized_key, use `purge_ssh_keys` on the user type instead"],"exampleFix":"# before\nresources { 'exec':\n  purge => true,\n}\n\n# after\n# exec cannot be enumerated; declare the execs you want instead\nexec { 'run-backup':\n  command => '/usr/local/bin/backup.sh',\n}","handlingStrategy":"validation","validationCode":"# only emit a purge declaration for enumerable types\nt = Puppet::Type.type(type_name.to_sym)\nif t&.respond_to?(:instances)\n  # ... emit resources { type_name: purge => true }\nend","typeGuard":"def purgeable?(type_name)\n  t = Puppet::Type.type(type_name.to_sym)\n  !t.nil? && t.respond_to?(:instances) && t.validproperty?(:ensure)\nend","tryCatchPattern":"begin\n  Puppet::Type.type(:resources).new(name: 'exec', purge: true)\nrescue ArgumentError => e\n  raise unless e.message.include?('cannot be queried')\n  # drop purge for this type\nend","preventionTips":["Check a type supports instances (and ensure) before writing purge declarations","When writing custom types, always implement self.instances","Prefer explicit resource management over purge for non-enumerable types"],"tags":["puppet","purge","metatype","custom-type"],"backgroundTag":"unsupported-operation","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}