puppetlabs/puppet · error · Puppet::ParseError

The %{label}-Type cannot be parameterized using an empty par

Error message

The %{label}-Type cannot be parameterized using an empty parameter list

What it means

Parameterizing an Object type skips arguments equal to :default (and named entries whose value is :default), binding only concrete values. If nothing binds - because the only argument was default, an all-default hash, or fewer positional values than parameters with the rest defaulted - Puppet::ParseError reports that the type cannot be parameterized with an empty parameter list.

Source

Thrown at lib/puppet/pops/types/p_object_type_extension.rb:85

      hash = init_parameters[0]
      hash.each_pair do |pn, pv|
        tp = pts[pn]
        if tp.nil?
          raise Puppet::ParseError, _("'%{pn}' is not a known type parameter for %{label}-Type") % { pn: pn, label: base_type.label }
        end

        by_name[pn] = check_param(tp, pv) unless pv == :default
      end
    else
      pts.values.each_with_index do |tp, idx|
        if idx < init_parameters.size
          pv = init_parameters[idx]
          by_name[tp.name] = check_param(tp, pv) unless pv == :default
        end
      end
    end
    if by_name.empty?
      raise Puppet::ParseError, _('The %{label}-Type cannot be parameterized using an empty parameter list') % { label: base_type.label }
    end

    @parameters = by_name
  end

  def check_param(type_param, v)
    TypeAsserter.assert_instance_of(nil, type_param.type, v) { type_param.label }
  end

  # Return the parameter values as positional arguments with unset values as :default. The
  # array is stripped from trailing :default values
  # @return [Array] the parameter values
  # @api private
  def init_parameters
    pts = @base_type.type_parameters(true)
    if pts.size > 2
      @parameters
    else

View on GitHub (pinned to e227c27540)

Solutions

  1. Pass at least one concrete parameter value: MyApp::Color[3]
  2. If you want the unparameterized type, use the bare name MyApp::Color instead of MyApp::Color[default]
  3. In Ruby generators, skip creating the extension entirely when all parameter values are :default

Example fix

# before
$filtered = MyApp::Color[default]   # binds nothing -> ParseError

# after
$plain    = MyApp::Color            # unparameterized base type
$filtered = MyApp::Color[3]         # at least one concrete value
Defensive patterns

Strategy: validation

Validate before calling

# ensure at least one parameter binds a concrete value
concrete = args.compact.reject { |v| v == :default }
raise 'nothing to parameterize: all values are default' if concrete.empty?
# or skip parameterization entirely and use base_type itself

Type guard

def parameterizable_args?(args)
  args.any? { |v| !v.nil? && v != :default }
end

Try / catch

begin
  Puppet::Pops::Types::PObjectTypeExtension.create(base_type, args)
rescue Puppet::ParseError => e
  raise unless e.message =~ /empty parameter list/
  base_type  # caller decides: unparameterized type or raise upstream
end

Prevention

When it happens

Trigger: MyApp::Color[default], MyApp::Color[] corner cases produced programmatically, or MyApp::Color[{channel => default}]: every candidate value is :default so by_name ends up empty and the constructor raises.

Common situations: Programmatic type construction that forwards optional arguments and ends up passing only defaults; template code that parameterizes unconditionally even when no filter values are set.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/4ace7d09edba63d1. Report an issue: GitHub.