puppetlabs/puppet · error · ArgumentError
Purging resources of type %{res_type} is not supported, sinc
Error message
Purging resources of type %{res_type} is not supported, since they cannot be queried from the system What it means
`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".
Source
Thrown at lib/puppet/type/resources.rb:36
raise ArgumentError, _("Could not find resource type '%{name}'") % { name: name } unless Puppet::Type.type(name)
end
munge(&:to_s)
end
newparam(:purge, :boolean => true, :parent => Puppet::Parameter::Boolean) do
desc "Whether to purge unmanaged resources. When set to `true`, this will
delete any resource that is not specified in your configuration and is not
autorequired by any managed resources. **Note:** The `ssh_authorized_key`
resource type can't be purged this way; instead, see the `purge_ssh_keys`
attribute of the `user` type."
defaultto :false
validate do |value|
if munge(value)
unless @resource.resource_type.respond_to?(:instances)
raise ArgumentError, _("Purging resources of type %{res_type} is not supported, since they cannot be queried from the system") % { res_type: @resource[:name] }
end
raise ArgumentError, _("Purging is only supported on types that accept 'ensure'") unless @resource.resource_type.validproperty?(:ensure)
end
end
end
newparam(:unless_system_user) do
desc "This keeps system users from being purged. By default, it
does not purge users whose UIDs are less than the minimum UID for the system (typically 500 or 1000), but you can specify
a different UID as the inclusive limit."
newvalues(:true, :false, /^\d+$/)
munge do |value|
case value
when /^\d+/
Integer(value)
when :true, trueView on GitHub (pinned to e227c27540)
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
Example fix
# before
resources { 'exec':
purge => true,
}
# after
# exec cannot be enumerated; declare the execs you want instead
exec { 'run-backup':
command => '/usr/local/bin/backup.sh',
} Defensive patterns
Strategy: validation
Validate before calling
# only emit a purge declaration for enumerable types
t = Puppet::Type.type(type_name.to_sym)
if t&.respond_to?(:instances)
# ... emit resources { type_name: purge => true }
end Type guard
def purgeable?(type_name) t = Puppet::Type.type(type_name.to_sym) !t.nil? && t.respond_to?(:instances) && t.validproperty?(:ensure) end
Try / catch
begin
Puppet::Type.type(:resources).new(name: 'exec', purge: true)
rescue ArgumentError => e
raise unless e.message.include?('cannot be queried')
# drop purge for this type
end Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- Purging is only supported on types that accept 'ensure'
- Unable to connect to the server at %{uri}. Detail: %{detail}
- Cannot use an unspecific Class[] Type
- Supported values for Property#array_matching are 'first' and
- Attempt to redefine method %{method} with block
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/f5fcb6537bc58bb7.
Report an issue: GitHub.