puppetlabs/puppet · error · ArgumentError
Could not find indirection '%{indirection}'
Error message
Could not find indirection '%{indirection}' What it means
Puppet::Indirector::Request#model resolves the request's indirection_name through the global indirection registry (Puppet::Indirector::Indirection.instance). If no indirection was ever registered under that name, ArgumentError is raised. Registration happens when the model class calls e.g. extend Puppet::Indirector (indirects :catalog), so a typo'd name, or referencing an indirection whose defining file was never required, produces this error.
Source
Thrown at lib/puppet/indirector/request.rb:104
@key = key
end
end
@key = @instance.name if !@key and @instance
end
# Look up the indirection based on the name provided.
def indirection
Puppet::Indirector::Indirection.instance(indirection_name)
end
def indirection_name=(name)
@indirection_name = name.to_sym
end
def model
ind = indirection
raise ArgumentError, _("Could not find indirection '%{indirection}'") % { indirection: indirection_name } unless ind
ind.model
end
# Are we trying to interact with multiple resources, or just one?
def plural?
method == :search
end
def initialize_from_hash(hash)
@indirection_name = hash['indirection_name'].to_sym
@method = hash['method'].to_sym
@key = hash['key']
@instance = hash['instance']
@options = hash['options']
end
def to_data_hashView on GitHub (pinned to e227c27540)
Solutions
- List registered indirections to verify the spelling: check each model class (Puppet::Node.indirects :node, Puppet::Resource::Catalog.indirects :catalog)
- Require the model file explicitly before building the request: require 'puppet/node' etc.
- Use the model's own indirection API instead of hand-built requests: Puppet::Node.indirection.find(key)
- Inspect the request hash/serialization you are loading and correct the indirection_name value
Example fix
# before req = Puppet::Indirection::Request.new(:nodes, :find, 'web01', nil) req.model # ArgumentError: Could not find indirection 'nodes' # after req = Puppet::Indirection::Request.new(:node, :find, 'web01', nil) req.model # => Puppet::Node
Defensive patterns
Strategy: validation
Validate before calling
unless Puppet::Indirector::Indirection.instance(indirection_name.to_sym)
raise ArgumentError, "indirection '#{indirection_name}' is not registered; require its model first"
end Type guard
def registered_indirection?(name) !Puppet::Indirector::Indirection.instance(name.to_sym).nil? end
Prevention
- Prefer model-level APIs (Puppet::Node.indirection.find) over hand-built Request objects
- Require the model file before constructing requests in isolated tooling/tests
- Assert indirection names with symbols taken from the model classes, not typed strings
When it happens
Trigger: Constructing Puppet::Indirector::Request.new(:nonexistent, :find, key, ...) in code or tests; deserializing a request from YAML with an indirection_name whose model class is not loaded; misspelling an indirection in custom faces or report tools (e.g., :nodes instead of :node).
Common situations: Custom tooling or RSpec fixtures that build Request objects directly with guessed names; code paths that lazy-load models in a different order than production; renames of indirections across Puppet versions.
Related errors
- Could not understand URL %{key}: %{detail}
- You can only save objects that respond to :name
- puppet.tasks/unparseable-metadata
- Listing remote file buckets is not allowed
- Invalid terminus name %{terminus_class}
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/8f82da7ae9f963bd.
Report an issue: GitHub.