{"record":{"id":"2c7bcd4dca94d687","repo":"puppetlabs/puppet","slug":"custom-functions-must-be-called-with-a-single-arra","errorCode":null,"errorMessage":"custom functions must be called with a single array that contains the arguments. For example, function_example([1]) instead of function_example(1)","messagePattern":"custom functions must be called with a single array that contains the arguments\\. For example, function_example\\(\\[1\\]\\) instead of function_example\\(1\\)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/parser/functions.rb","lineNumber":222,"sourceCode":"    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\n\n  # Determine if a function is defined\n  #\n  # @param [Symbol] name the function\n  # @param [Puppet::Node::Environment] environment the environment to find the function in\n  #\n  # @return [Symbol, false] The name of the function if it's defined,","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/parser/functions.rb#L204-L240","documentation":"Error \"custom functions must be called with a single array that contains the arguments. For example, function_example([1]) instead of function_example(1)\" thrown in puppetlabs/puppet.","triggerScenarios":"Thrown at lib/puppet/parser/functions.rb:222 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"}