{"record":{"id":"de26913b325c96f8","repo":"puppetlabs/puppet","slug":"block-param-accepts-max-2-arguments-type-name","errorCode":null,"errorMessage":"block_param accepts max 2 arguments (type, name), got %{size}.","messagePattern":"block_param accepts max 2 arguments \\(type, name\\), got %(.+?)\\.","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/functions.rb","lineNumber":488,"sourceCode":"\n    # Defines one required block parameter that may appear last. If type and name is missing the\n    # default type is \"Callable\", and the name is \"block\". If only one\n    # parameter is given, then that is the name and the type is \"Callable\".\n    #\n    # @api public\n    def block_param(*type_and_name)\n      case type_and_name.size\n      when 0\n        type = @all_callables\n        name = :block\n      when 1\n        type = @all_callables\n        name = type_and_name[0]\n      when 2\n        type, name = type_and_name\n        type = Puppet::Pops::Types::TypeParser.singleton.parse(type, loader) unless type.is_a?(Puppet::Pops::Types::PAnyType)\n      else\n        raise ArgumentError, _(\"block_param accepts max 2 arguments (type, name), got %{size}.\") % { size: type_and_name.size }\n      end\n\n      unless Puppet::Pops::Types::TypeCalculator.is_kind_of_callable?(type, false)\n        raise ArgumentError, _(\"Expected PCallableType or PVariantType thereof, got %{type_class}\") % { type_class: type.class }\n      end\n\n      unless name.is_a?(Symbol)\n        raise ArgumentError, _(\"Expected block_param name to be a Symbol, got %{name_class}\") % { name_class: name.class }\n      end\n\n      if @block_type.nil?\n        @block_type = type\n        @block_name = name\n      else\n        raise ArgumentError, _('Attempt to redefine block')\n      end\n    end\n    alias required_block_param block_param","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/functions.rb#L470-L506","documentation":"block_param accepts zero, one, or two arguments: (), (name), or (type, name). Any third argument raises this ArgumentError at definition time. The case/size dispatch in the ParameterDsl has no branch above 2.","triggerScenarios":"block_param 'Callable', :block, 'extra' inside a dispatch block; usually a copy-paste of a param line into block_param, or a mistaken belief that block_param takes a default value argument.","commonSituations":"Editing existing dispatch blocks; converting a param declaration into a block declaration and leaving extra arguments behind.","solutions":["Pass at most two arguments: a type reference and a Symbol name.","For defaults, use block_param with no arguments: the default is type Callable and name :block.","For an optional block with a default of nil in the method, use optional_block_param instead of extra arguments."],"exampleFix":"# before\n block_param 'Callable', :block, 'unused'\n\n# after\n block_param 'Callable', :block\n # or simply: block_param   -> Callable, :block","handlingStrategy":"validation","validationCode":"# CI grep: block_param called with three or more comma-separated arguments\n! grep -rnE \"block_param[[:space:]]+[^,]+,[^,]+,\" lib/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember the three legal shapes: block_param, block_param :name, block_param 'Type', :name.","Block defaults are expressed with optional_block_param, not with extra arguments.","Delete leftover arguments when converting a param line into block_param."],"tags":["puppet","functions","block-param","arity","dsl"],"backgroundTag":"too-many-arguments","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}