{"record":{"id":"b07bbb805dba620d","repo":"puppetlabs/puppet","slug":"expected-block-param-name-to-be-a-symbol-got-na","errorCode":null,"errorMessage":"Expected block_param name to be a Symbol, got %{name_class}","messagePattern":"Expected block_param name to be a Symbol, got %(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/functions.rb","lineNumber":496,"sourceCode":"      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\n\n    # Defines one optional block parameter that may appear last. If type or name is missing the\n    # defaults are \"any callable\", and the name is \"block\". The implementor of the dispatch target\n    # must use block = nil when it is optional (or an error is raised when the call is made).\n    #\n    # @api public\n    def optional_block_param(*type_and_name)\n      # same as required, only wrap the result in an optional type","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/functions.rb#L478-L514","documentation":"The name given to block_param must be a Symbol. With one argument that argument is taken as the name; with two, the second is the name. Passing a String (for example 'block') fails the Symbol check and raises this ArgumentError at definition time.","triggerScenarios":"block_param 'block' (a single String is treated as the name), or block_param 'Callable', 'block'. Both leave name as a String at the is_a?(Symbol) check.","commonSituations":"Copy-paste of param declarations where strings are common; forgetting that DSL names in dispatch blocks are Symbols.","solutions":["Write the name as a Symbol: block_param 'Callable', :block.","With a single argument, pass the Symbol name only: block_param :block.","Adopt the convention that every name in a dispatch block (param names included) is written with a leading colon."],"exampleFix":"# before\n block_param 'Callable', 'block'\n block_param 'block'\n\n# after\n block_param 'Callable', :block\n block_param :block","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"# Every DSL name argument must be a Symbol\nname_guard = ->(name) { name.is_a?(Symbol) }\nraise ArgumentError, 'pass :block not \"block\"' unless name_guard.call(:block)","tryCatchPattern":null,"preventionTips":["Write names with a leading colon everywhere in dispatch blocks.","Call to_sym on generated names before passing them.","Treat quoted names in a dispatch block as a smell to fix on sight."],"tags":["puppet","functions","block-param","symbol","type-validation"],"backgroundTag":"invalid-parameter-name","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}