{"record":{"id":"6e5b2e50a30c8e0c","repo":"puppetlabs/puppet","slug":"pn-is-not-a-known-type-parameter-for-label","errorCode":null,"errorMessage":"'%{pn}' is not a known type parameter for %{label}-Type","messagePattern":"'%(.+?)' is not a known type parameter for %(.+?)-Type","errorType":"exception","errorClass":"Puppet::ParseError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/p_object_type_extension.rb","lineNumber":71,"sourceCode":"  def initialize(base_type, init_parameters)\n    pts = base_type.type_parameters(true)\n    raise Puppet::ParseError, _('The %{label}-Type cannot be parameterized using []') % { label: base_type.label } if pts.empty?\n\n    @base_type = base_type\n\n    named_args = init_parameters.size == 1 && init_parameters[0].is_a?(Hash)\n    if named_args\n      # Catch case when first parameter is an assignable Hash\n      named_args = pts.size >= 1 && !pts.values[0].type.instance?(init_parameters[0])\n    end\n\n    by_name = {}\n    if named_args\n      hash = init_parameters[0]\n      hash.each_pair do |pn, pv|\n        tp = pts[pn]\n        if tp.nil?\n          raise Puppet::ParseError, _(\"'%{pn}' is not a known type parameter for %{label}-Type\") % { pn: pn, label: base_type.label }\n        end\n\n        by_name[pn] = check_param(tp, pv) unless pv == :default\n      end\n    else\n      pts.values.each_with_index do |tp, idx|\n        if idx < init_parameters.size\n          pv = init_parameters[idx]\n          by_name[tp.name] = check_param(tp, pv) unless pv == :default\n        end\n      end\n    end\n    if by_name.empty?\n      raise Puppet::ParseError, _('The %{label}-Type cannot be parameterized using an empty parameter list') % { label: base_type.label }\n    end\n\n    @parameters = by_name\n  end","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/p_object_type_extension.rb#L53-L89","documentation":"When an Object type is parameterized with a single Hash argument that is not itself assignable to the first type parameter, the hash is treated as named arguments: each key must be a declared type parameter name of the base type. An unknown key raises Puppet::ParseError naming the key and the type.","triggerScenarios":"MyApp::Color[{colour => 3}] when the declared type parameter is channel; also triggered by hash keys matching only an attribute name instead of a type parameter name. Note that a hash assignable to the first type parameter's type is instead bound positionally as that parameter's value.","commonSituations":"Typos or spelling differences (colour vs channel, UK/US variants); using attribute names in the parameterization hash; renaming a type parameter without updating call sites.","solutions":["Use exactly the declared type parameter names as hash keys: MyApp::Color[{channel => 3}]","If the name is right but undefined, declare it under type_parameters in the Object definition","Remember each value is type-checked against the parameter's declared type (check_param), so also verify the value kind"],"exampleFix":"# before\ntype MyApp::Color = Object[{ type_parameters => { channel => Integer } }]\n$bad = MyApp::Color[{colour => 3}]   # 'colour' is not a type parameter\n\n# after\n$good = MyApp::Color[{channel => 3}]","handlingStrategy":"validation","validationCode":"# named-argument keys must all be declared type parameter names\nknown = base_type.type_parameters(true).keys\nunknown = arg_hash.keys - known\nraise \"unknown type parameters: #{unknown.inspect}; known: #{known.inspect}\" unless unknown.empty?","typeGuard":"def valid_type_param_keys?(base_type, hash)\n  (hash.keys - base_type.type_parameters(true).keys).empty?\nend","tryCatchPattern":"begin\n  Puppet::Pops::Types::PObjectTypeExtension.create(base_type, [hash])\nrescue Puppet::ParseError => e\n  raise unless e.message =~ /is not a known type parameter/\n  raise  # e.message names the bad key and the type\nend","preventionTips":["Copy type parameter names verbatim from the type definition","When renaming a type parameter, grep call sites for the old name"],"tags":["puppet","pcore","object-type","type-parameters","unknown-key"],"backgroundTag":"invalid-type-parameterization","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}