{"record":{"id":"3ae7a2e274fca04e","repo":"puppetlabs/puppet","slug":"illegalstruct-member-key-type-expected-notundef","errorCode":null,"errorMessage":"IllegalStruct member key type. Expected NotUndef, Optional, String, or Enum. Got: #{key_type.class.name}","messagePattern":"IllegalStruct member key type\\. Expected NotUndef, Optional, String, or Enum\\. Got: #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/type_factory.rb","lineNumber":201,"sourceCode":"\n        key_type = string(key_type)\n        # Must make key optional if the value can be Undef\n        key_type = optional(key_type) if tc.assignable?(value_type, PUndefType::DEFAULT)\n      else\n        # assert that the key type is one of String[1], NotUndef[String[1]] and Optional[String[1]]\n        case key_type\n        when PNotUndefType\n          # We can loose the NotUndef wrapper here since String[1] isn't optional anyway\n          key_type = key_type.type\n          s = key_type\n        when POptionalType\n          s = key_type.optional_type\n        when PStringType\n          s = key_type\n        when PEnumType\n          s = key_type.values.size == 1 ? PStringType.new(key_type.values[0]) : nil\n        else\n          raise ArgumentError, \"Illegal Struct member key type. Expected NotUndef, Optional, String, or Enum. Got: #{key_type.class.name}\"\n        end\n        unless s.is_a?(PStringType) && !s.value.nil?\n          raise ArgumentError, \"Unable to extract a non-empty literal string from Struct member key type #{tc.string(key_type)}\"\n        end\n      end\n      PStructElement.new(key_type, value_type)\n    end\n    PStructType.new(elements)\n  end\n\n  # Produces an `Object` type from the given _hash_ that represents the features of the object\n  #\n  # @param hash [{String=>Object}] the hash of feature groups\n  # @return [PObjectType] the created type\n  #\n  def self.object(hash = nil, loader = nil)\n    hash.nil? || hash.empty? ? PObjectType::DEFAULT : PObjectType.new(hash, loader)\n  end","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/type_factory.rb#L183-L219","documentation":"Error \"IllegalStruct member key type. Expected NotUndef, Optional, String, or Enum. Got: #{key_type.class.name}\" thrown in puppetlabs/puppet.","triggerScenarios":"Thrown at lib/puppet/pops/types/type_factory.rb:201 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}