{"record":{"id":"da95a4c80a0df50c","repo":"puppetlabs/puppet","slug":"parameter-type-must-be-a-string-reference-to-a-p","errorCode":null,"errorMessage":"Parameter 'type' must be a String reference to a Puppet Data Type. Got %{type_class}","messagePattern":"Parameter 'type' must be a String reference to a Puppet Data Type\\. Got %(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/functions.rb","lineNumber":552,"sourceCode":"    def internal_param(type, name, repeat = false)\n      raise ArgumentError, _('Parameters cannot be added after a block parameter') unless @block_type.nil?\n      raise ArgumentError, _('Parameters cannot be added after a repeated parameter') if @max == :default\n\n      if name.is_a?(String)\n        raise ArgumentError, _(\"Parameter name argument must be a Symbol. Got %{name_class}\") % { name_class: name.class }\n      end\n\n      if type.is_a?(String) || type.is_a?(Puppet::Pops::Types::PAnyType)\n        @types << type\n        @names << name\n        # mark what should be picked for this position when dispatching\n        if repeat\n          @weaving << -@names.size()\n        else\n          @weaving << @names.size() - 1\n        end\n      else\n        raise ArgumentError, _(\"Parameter 'type' must be a String reference to a Puppet Data Type. Got %{type_class}\") % { type_class: type.class }\n      end\n    end\n\n    # @api private\n    def dispatch(meth_name, argument_mismatch_handler, &block)\n      # an array of either an index into names/types, or an array with\n      # injection information [type, name, injection_name] used when the call\n      # is being made to weave injections into the given arguments.\n      #\n      @types = []\n      @names = []\n      @weaving = []\n      @injections = []\n      @min = 0\n      @max = 0\n      @block_type = nil\n      @block_name = nil\n      @return_type = nil","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/functions.rb#L534-L570","documentation":"The type argument to param-style declarations must be a String reference to a Puppet data type, or an already constructed PAnyType instance. A Ruby class, Symbol, or any other object fails the check in internal_param and raises this ArgumentError at definition time.","triggerScenarios":"param Integer, :count (a Ruby Class), or param :x (a Symbol). Only param 'Integer', :count or a Puppet::Pops::Types object is accepted.","commonSituations":"Ruby muscle memory (Integer looks natural after writing plain Ruby); refactors that replace quoted strings with constants; leftover Symbols from name-only lines.","solutions":["Quote the type reference: param 'Integer', :count.","Or pass a constructed type, for example Puppet::Pops::Types::TypeFactory.integer.","Prefer the quoted-string form for readability; keep Ruby constants out of the type position."],"exampleFix":"# before\n param Integer, :count\n param :count\n\n# after\n param 'Integer', :count\n param Puppet::Pops::Types::TypeFactory.integer, :count","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"type_arg_guard = ->(t) { t.is_a?(String) || t.is_a?(Puppet::Pops::Types::PAnyType) }\nraise ArgumentError, 'type must be a String data-type reference' unless type_arg_guard.call('Integer')","tryCatchPattern":null,"preventionTips":["Never pass Ruby classes (Integer, String) or Symbols as the type argument.","Use quoted Puppet type references: 'Integer', 'Array[String]'.","Use TypeFactory objects when types are computed programmatically."],"tags":["puppet","functions","dispatch","type-validation","dsl"],"backgroundTag":"invalid-parameter-type","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}