puppetlabs/puppet · error · ArgumentError
Unknown resource type %{type}
Error message
Unknown resource type %{type} What it means
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.
Source
Thrown at lib/puppet/resource/catalog.rb:293
@resource_table.values.each(&:remove) if remove_resources
@resource_table.clear
@resources = []
if @relationship_graph
@relationship_graph.clear
@relationship_graph = nil
end
end
def classes
@classes.dup
end
# Create a new resource and register it in the catalog.
def create_resource(type, options)
klass = Puppet::Type.type(type)
unless klass
raise ArgumentError, _("Unknown resource type %{type}") % { type: type }
end
resource = klass.new(options)
return unless resource
add_resource(resource)
resource
end
# Make sure all of our resources are "finished".
def finalize
make_default_resources
@resource_table.values.each(&:finish)
write_graph(:resources)
end
View on GitHub (pinned to e227c27540)
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).
Example fix
# before
catalog.create_resource('myservice', ensure: 'running')
# after
type = Puppet::Type.type(:myservice)
raise ArgumentError, 'myservice type not loadable; is its module on the modulepath?' unless type
catalog.create_resource(:myservice, ensure: 'running') Defensive patterns
Strategy: validation
Validate before calling
unless Puppet::Type.type(type)
raise ArgumentError, "type #{type.inspect} not registered; check spelling and that its module is on the modulepath"
end
catalog.create_resource(type, options) Type guard
loadable_type = ->(t) { !Puppet::Type.type(t).nil? } Try / catch
begin
catalog.create_resource(type, options)
rescue ArgumentError => e
raise unless e.message.include?('Unknown resource type')
# log available types to help diagnosis
Puppet.debug(Puppet::Type.alltypes.map(&:name).join(','))
raise
end Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not find type %{request_type}
- Invalid entry at %{error_location}: '%{file_text}'
- %{mount} is already mounted at %{name} at %{error_location}
- Fileset paths must be fully qualified: %{path}
- Fileset paths must exist
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/6177e7b1b7d35904.
Report an issue: GitHub.