puppetlabs/puppet · error · ArgumentError
%{name}(): Wrong number of arguments given (%{arg_count} for
Error message
%{name}(): Wrong number of arguments given (%{arg_count} for %{arity}) What it means
Error "%{name}(): Wrong number of arguments given (%{arg_count} for %{arity})" thrown in puppetlabs/puppet.
Source
Thrown at lib/puppet/parser/functions.rb:213
ftype = options[:type] || :statement
unless ftype == :statement or ftype == :rvalue
raise Puppet::DevError, _("Invalid statement type %{type}") % { type: ftype.inspect }
end
# the block must be installed as a method because it may use "return",
# which is not allowed from procs.
real_fname = "real_function_#{name}"
environment_module(environment).send(:define_method, real_fname, &block)
fname = "function_#{name}"
env_module = environment_module(environment)
env_module.send(:define_method, fname) do |*args|
Puppet::Util::Profiler.profile(_("Called %{name}") % { name: name }, [:functions, name]) do
if args[0].is_a? Array
if arity >= 0 and args[0].size != arity
raise ArgumentError, _("%{name}(): Wrong number of arguments given (%{arg_count} for %{arity})") % { name: name, arg_count: args[0].size, arity: arity }
elsif arity < 0 and args[0].size < (arity + 1).abs
raise ArgumentError, _("%{name}(): Wrong number of arguments given (%{arg_count} for minimum %{min_arg_count})") % { name: name, arg_count: args[0].size, min_arg_count: (arity + 1).abs }
end
r = Puppet::Pops::Evaluator::Runtime3FunctionArgumentConverter.convert_return(send(real_fname, args[0]))
# avoid leaking aribtrary value if not being an rvalue function
options[:type] == :rvalue ? r : nil
else
raise ArgumentError, _("custom functions must be called with a single array that contains the arguments. For example, function_example([1]) instead of function_example(1)")
end
end
end
func = { :arity => arity, :type => ftype, :name => fname }
func[:doc] = options[:doc] if options[:doc]
env_module.add_function_info(name, func)
View on GitHub (pinned to e227c27540)
When it happens
Trigger: Thrown at lib/puppet/parser/functions.rb:213 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/096c6d94c521cdca.
Report an issue: GitHub.