{"record":{"id":"76372ad349c625b1","repo":"FasterXML/jackson-databind","slug":"missing-generic-type-information-for-type","errorCode":null,"errorMessage":"Missing generic type information for ${type}","messagePattern":"Missing generic type information for (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/jdk/MapEntryDeserializer.java","lineNumber":61,"sourceCode":"    /**\n     * If value instances have polymorphic type information, this\n     * is the type deserializer that can handle it\n     */\n    protected final TypeDeserializer _valueTypeDeserializer;\n\n    /*\n    /**********************************************************************\n    /* Life-cycle\n    /**********************************************************************\n     */\n\n    public MapEntryDeserializer(JavaType type,\n            KeyDeserializer keyDeser, ValueDeserializer<Object> valueDeser,\n            TypeDeserializer valueTypeDeser)\n    {\n        super(type);\n        if (type.containedTypeCount() != 2) { // sanity check\n            throw new IllegalArgumentException(\"Missing generic type information for \"+type);\n        }\n        _keyDeserializer = keyDeser;\n        _valueDeserializer = valueDeser;\n        _valueTypeDeserializer = valueTypeDeser;\n    }\n\n    protected MapEntryDeserializer(MapEntryDeserializer src,\n            KeyDeserializer keyDeser, ValueDeserializer<Object> valueDeser,\n            TypeDeserializer valueTypeDeser)\n    {\n        super(src);\n        _keyDeserializer = keyDeser;\n        _valueDeserializer = valueDeser;\n        _valueTypeDeserializer = valueTypeDeser;\n    }\n\n    /**\n     * Factory method for constructing initial (non-contextual) instances.","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/deser/jdk/MapEntryDeserializer.java#L43-L79","documentation":"Thrown by the MapEntryDeserializer constructor as a sanity check when the JavaType for a Map.Entry<K,V> does not have exactly 2 contained type parameters. Map.Entry is parameterized over key and value types; if type resolution produces a type with 0, 1, or 3+ contained types (e.g., raw Map.Entry from type erasure), the constructor rejects it. This is a type-resolution or configuration error, not a data error.","triggerScenarios":"Constructing MapEntryDeserializer for a raw Map.Entry type (no generics). A custom deserializer factory that passes an incorrectly resolved JavaType. Type erasure where a field is declared as raw Map.Entry without type parameters.","commonSituations":"Declaring a field or parameter as raw Map.Entry (no <K,V>). Using a TypeReference or TypeFactory incorrectly to build a Map.Entry type. Framework code that constructs the deserializer manually with a wrong JavaType.","solutions":["Always parameterize Map.Entry fields/parameters: Map.Entry<String,Integer> not raw Map.Entry.","If constructing the type programmatically, use TypeFactory.constructParametricType(Map.Entry.class, keyType, valueType) to ensure 2 contained types.","Check custom DeserializerFactory code for incorrect JavaType construction.","Use a TypeReference<Map.Entry<K,V>> when registering deserializers."],"exampleFix":"// before: raw Map.Entry type\nObjectMapper mapper = ...;\nMap.Entry result = mapper.readValue(json, Map.Entry.class);\n// after: parameterized type\nMap.Entry<String,Integer> result = mapper.readValue(json,\n    new TypeReference<Map.Entry<String,Integer>>() {});","handlingStrategy":"type-guard","validationCode":"// Ensure Map.Entry type has exactly 2 contained types before constructing\nJavaType entryType = typeFactory.constructType(new TypeReference<Map.Entry<String,Integer>>() {});\nif (entryType.containedTypeCount() != 2) {\n    throw new IllegalArgumentException(\"Map.Entry needs 2 type params: \" + entryType);\n}","typeGuard":"static boolean isValidEntryType(JavaType type) {\n    return type.getRawClass() == Map.Entry.class && type.containedTypeCount() == 2;\n}","tryCatchPattern":null,"preventionTips":["Always parameterize Map.Entry: Map.Entry<K,V>, never raw Map.Entry.","Use TypeReference<Map.Entry<K,V>> when deserializing.","In custom factories, validate containedTypeCount()==2 before constructing the deserializer."],"tags":["jackson","deserialization","map-entry","type-resolution","generic-types"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}