puppetlabs/puppet · error · ArgumentError
Node names cannot be nil
Error message
Node names cannot be nil
What it means
Puppet::Node.new raises ArgumentError immediately when the name argument is nil. The name keys catalogs, certificates and reports, so a node without an identity is meaningless and no defaulting is applied here; the caller must supply a truthy value, normally the certname.
Source
Thrown at lib/puppet/node.rb:101
@environment = Puppet.lookup(:environments).get!(env)
else
@environment = env
end
# Keep environment_name attribute and parameter in sync if they have been set
unless @environment.nil?
# always set the environment parameter. It becomes top scope $environment for a manifest during catalog compilation.
@parameters[ENVIRONMENT] = @environment.name.to_s
self.environment_name = @environment.name
end
end
def has_environment_instance?
!@environment.nil?
end
def initialize(name, options = {})
raise ArgumentError, _("Node names cannot be nil") unless name
@name = name
classes = options[:classes]
if classes
if classes.is_a?(String)
@classes = [classes]
else
@classes = classes
end
else
@classes = []
end
@parameters = options[:parameters] || {}
@facts = options[:facts]
View on GitHub (pinned to e227c27540)
Solutions
- Pass a concrete name, normally Puppet[:certname] or the request's node parameter
- Default earlier in the call chain: name ||= Puppet[:certname] before constructing
- Fix the upstream nil: find why the variable holding the name is empty
- Add a unit test asserting a non-nil name at the construction site
Example fix
# before node = Puppet::Node.new(params[:node]) # after node = Puppet::Node.new(params[:node] || Puppet[:certname])
Defensive patterns
Strategy: type-guard
Type guard
def node_name?(value) !value.nil? && (value.is_a?(String) || value.is_a?(Symbol)) && !value.to_s.empty? end raise ArgumentError, 'node name required' unless node_name?(name)
Prevention
- Default node names to the certname at the system boundary
- Fail fast on nil identity data; never pass nil through hoping for a downstream default
When it happens
Trigger: Puppet::Node.new(nil), Puppet::Node.new(options[:node_name]) where the option was never set, or building a node from a lookup (e.g. an ENC result or parameter) that returned nil.
Common situations: Wrapper scripts computing the node name from an unset variable; nil returned silently by an external node classifier; test fixtures that forget the name argument.
Related errors
- Cannot disable unrecognized warning types '%{invalid}'. Vali
- Invalid value '%{value}' for parameter %{name}. Allowed valu
- Errors while validating epp
- One or more file(s) specified did not exist: %{files}
- a data type must have an interface
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/ccef62111c6a1b3f.
Report an issue: GitHub.