puppetlabs/puppet · error · ArgumentError
after_action takes three arguments, action, args, and option
Error message
after_action takes three arguments, action, args, and options
What it means
OptionBuilder#after_action enforces `block.arity == 3` because it calls the hook with (action, args, options) (lib/puppet/interface/option_builder.rb:76). Any other declared arity — fewer parameters, splats, or inexact procs — fails the strict equality check at face load.
Source
Thrown at lib/puppet/interface/option_builder.rb:76
@option.before_action = block
end
# Sets a block to be executed after an action is invoked.
# !(see before_action)
# @api public
# @dsl Faces
def after_action(&block)
unless block
# TRANSLATORS 'after_action' is a method name and should not be translated
raise ArgumentError, _("%{option} after_action requires a block") % { option: @option }
end
if @option.after_action
# TRANSLATORS 'after_action' is a method name and should not be translated
raise ArgumentError, _("%{option} already has an after_action set") % { option: @option }
end
unless block.arity == 3 then
# TRANSLATORS 'after_action' is a method name and should not be translated
raise ArgumentError, _("after_action takes three arguments, action, args, and options")
end
@option.after_action = block
end
# Sets whether the option is required. If no argument is given it
# defaults to setting it as a required option.
# @api public
# @dsl Faces
def required(value = true)
@option.required = value
end
# Sets a block that will be used to compute the default value for this
# option. It will be evaluated when the action is invoked. The block
# should take no arguments.
# @api public
# @dsl FacesView on GitHub (pinned to e227c27540)
Solutions
- Declare exactly three parameters: `after_action { |action, args, options| ... }`
- Underscore the ones you ignore: `|_action, _args, options|`
- Check `hook.arity == 3` before registering hooks held in variables
Example fix
# before
after_action { |action, options| log(action) }
# after
after_action { |action, args, options| log(action) } Defensive patterns
Strategy: validation
Validate before calling
hook = proc { |action, args, options| log(action) }
raise ArgumentError, 'after_action hook must take exactly 3 args' unless hook.arity == 3
after_action(&hook) Prevention
- Use the exact `|action, args, options|` signature for after_action too
- No splat hooks — arity must equal 3
- Assert arity when hooks are stored in variables or config
When it happens
Trigger: `after_action { |action, args| ... }` (arity 2); `after_action { |*a| ... }` (arity -1).
Common situations: Trimming parameters after refactoring; splat-style hook blocks copied from logging helpers.
Related errors
- before_action takes three arguments, action, args, and optio
- %{option} default_to block should not take any arguments
- %{name} can't be optional and have a default value
- default value for %{name} is a %{class_name}, not a proc
- before action hook for %{name} is a %{class_name}, not a pro
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/6ec888d2bf9d5193.
Report an issue: GitHub.