{"record":{"id":"3cb1af82abe9b6be","repo":"puppetlabs/puppet","slug":"name-wrong-number-of-arguments-given-arg-3cb1af","errorCode":null,"errorMessage":"%{name}(): Wrong number of arguments given (%{arg_count} for minimum %{min_arg_count})","messagePattern":"%(.+?)\\(\\): Wrong number of arguments given \\(%(.+?) for minimum %(.+?)\\)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/parser/functions.rb","lineNumber":215,"sourceCode":"    unless ftype == :statement or ftype == :rvalue\n      raise Puppet::DevError, _(\"Invalid statement type %{type}\") % { type: ftype.inspect }\n    end\n\n    # the block must be installed as a method because it may use \"return\",\n    # which is not allowed from procs.\n    real_fname = \"real_function_#{name}\"\n    environment_module(environment).send(:define_method, real_fname, &block)\n\n    fname = \"function_#{name}\"\n    env_module = environment_module(environment)\n\n    env_module.send(:define_method, fname) do |*args|\n      Puppet::Util::Profiler.profile(_(\"Called %{name}\") % { name: name }, [:functions, name]) do\n        if args[0].is_a? Array\n          if arity >= 0 and args[0].size != arity\n            raise ArgumentError, _(\"%{name}(): Wrong number of arguments given (%{arg_count} for %{arity})\") % { name: name, arg_count: args[0].size, arity: arity }\n          elsif arity < 0 and args[0].size < (arity + 1).abs\n            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 }\n          end\n\n          r = Puppet::Pops::Evaluator::Runtime3FunctionArgumentConverter.convert_return(send(real_fname, args[0]))\n          # avoid leaking aribtrary value if not being an rvalue function\n          options[:type] == :rvalue ? r : nil\n        else\n          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)\")\n        end\n      end\n    end\n\n    func = { :arity => arity, :type => ftype, :name => fname }\n    func[:doc] = options[:doc] if options[:doc]\n\n    env_module.add_function_info(name, func)\n\n    func\n  end","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/parser/functions.rb#L197-L233","documentation":"Error \"%{name}(): Wrong number of arguments given (%{arg_count} for minimum %{min_arg_count})\" thrown in puppetlabs/puppet.","triggerScenarios":"Thrown at lib/puppet/parser/functions.rb:215 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}