{"record":{"id":"874032a6398d4948","repo":"puppetlabs/puppet","slug":"puppet-face-action-takes-arg-count-argume","errorCode":null,"errorMessage":"puppet %{face} %{action} takes %{arg_count} argument, but you gave %{given_count}","messagePattern":"puppet %(.+?) %(.+?) takes %(.+?) argument, but you gave %(.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/application/face_base.rb","lineNumber":250,"sourceCode":"    #                   # positional argument!!\n    #\n    # We could also fix this by making it mandatory to pass the options on\n    # every call, but that would make the Ruby API much more annoying to\n    # work with; having the defaulting is a much nicer convention to have.\n    #\n    # We could also pass the arguments implicitly, by having a magic\n    # 'options' method that was visible in the scope of the action, which\n    # returned the right stuff.\n    #\n    # That sounds attractive, but adds complications to all sorts of\n    # things, especially when you think about how to pass options when you\n    # are writing Ruby code that calls multiple faces.  Especially if\n    # faces are involved in that. ;)\n    #\n    # --daniel 2011-04-27\n    if (arity = @action.positional_arg_count) > 0\n      unless (count = arguments.length) == arity then\n        raise ArgumentError, n_(\"puppet %{face} %{action} takes %{arg_count} argument, but you gave %{given_count}\", \"puppet %{face} %{action} takes %{arg_count} arguments, but you gave %{given_count}\", arity - 1) % { face: @face.name, action: @action.name, arg_count: arity - 1, given_count: count - 1 }\n      end\n    end\n\n    if @face.deprecated?\n      Puppet.deprecation_warning(_(\"'puppet %{face}' is deprecated and will be removed in a future release\") % { face: @face.name })\n    end\n\n    result = @face.send(@action.name, *arguments)\n    puts render(result, arguments) unless result.nil?\n    status = true\n\n  # We need an easy way for the action to set a specific exit code, so we\n  # rescue SystemExit here; This allows each action to set the desired exit\n  # code by simply calling Kernel::exit.  eg:\n  #\n  #   exit(2)\n  #\n  # --kelsey 2012-02-14","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/application/face_base.rb#L232-L268","documentation":"Before dispatching a face action, FaceBase compares arguments.length with the action's positional_arg_count and raises ArgumentError (singular/plural wording via n_) on mismatch. The displayed counts subtract one on each side because the face name occupies one slot in the raw invocation; the comparison itself is raw length vs arity.","triggerScenarios":"Any 'puppet <face> <action> ...' where the number of positional words differs from the action's declared arity: 'puppet config set server extra value' (too many), 'puppet config set' (too few). Option flags and their values do not count.","commonSituations":"Scripts pinning old face syntax across puppet upgrades that changed arity; command lines with an extra pasted word; forgetting that some actions require positional arguments at all.","solutions":["Run puppet <face> <action> --help and count the POSITIONAL arguments it documents","Adjust the command to pass exactly that many positional words","If arity changed between versions, pin the command syntax to the puppet version you run"],"exampleFix":"# before\npuppet config set server extra puppet.example.com  # too many arguments\n\n# after\npuppet config set server puppet.example.com","handlingStrategy":"validation","validationCode":"arity = action.positional_arg_count\nraise ArgumentError, \"need #{arity} positional args\" unless args.length == arity\nface.send(action.name, *args)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check action.positional_arg_count before invoking faces programmatically","Read 'puppet <face> <action> --help' and count positional (non-flag) arguments","Pin CLI syntax per puppet version in wrapper scripts"],"tags":["cli","face","arity","puppet"],"backgroundTag":"wrong-argument-count","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}