{"record":{"id":"c4910dc8a6fe4d57","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 \"\\+type","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/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/src/main/java/tools/jackson/databind/deser/jdk/MapEntryDeserializer.java#L43-L79","documentation":"MapEntryDeserializer's constructor requires the JavaType to carry both type parameters of Map.Entry<K,V> (containedTypeCount()==2). A raw or partially parameterized Map.Entry type cannot be deserialized because the key and value deserializers cannot be located. The check throws IllegalArgumentException during deserializer construction.","triggerScenarios":"Passing Map.Entry.class (raw) to readValue or a TypeReference that does not capture both generics; a field of type Map.Entry without type arguments; a TypeFactory misconfiguration that drops generic info before deserializer lookup.","commonSituations":"Using mapper.readValue(json, Map.Entry.class) directly; reflection-based code that erases generics; legacy APIs returning raw Map.Entry; Kotlin/Scala interop where generic signatures are not preserved at the call site.","solutions":["Always deserialize Map.Entry with a TypeReference: new TypeReference<Map.Entry<String,Integer>>(){}.","Declare the target field/parameter as Map.Entry<K,V> with both type arguments present.","If generics are genuinely unknown, deserialize to a concrete pair type (e.g. AbstractMap.SimpleEntry) or to JsonNode and convert afterwards.","Audit TypeReference usage to ensure the anonymous subclass captures the bindings (do not use a generic helper method that erases them)."],"exampleFix":"// before\nMap.Entry<String,Integer> e = mapper.readValue(json, Map.Entry.class); // raw\n\n// after\nMap.Entry<String,Integer> e = mapper.readValue(json,\n    new TypeReference<Map.Entry<String,Integer>>(){});","handlingStrategy":"type-guard","validationCode":"JavaType t = mapper.constructType(targetClass);\nif (t.isTypeOrSubTypeOf(Map.Entry.class) && t.containedTypeCount() < 2) {\n    throw new IllegalArgumentException(\n        \"Cannot deserialize raw Map.Entry; provide generics via TypeReference\");\n}","typeGuard":"boolean isFullyParameterizedEntry(JavaType t) {\n    return t != null\n        && t.isTypeOrSubTypeOf(Map.Entry.class)\n        && t.containedTypeCount() == 2;\n}","tryCatchPattern":null,"preventionTips":["Always read Map.Entry via new TypeReference<Map.Entry<K,V>>(){}.","Never pass Map.Entry.class to readValue.","Static-check field declarations of Map.Entry to require both generic arguments."],"tags":["deserialization","map-entry","generics","type-resolution","illegal-argument"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}