{"record":{"id":"2d131145b26ee92e","repo":"apache/flink","slug":"could-not-create-the-type-information-for-th-2d1311","errorCode":null,"errorMessage":"Could not create the type information for '{}'. The most common reason is failure to infer the generic type information, due to Java's type erasure. In that case, please pass a 'TypeHint' instead of a class to describe the type. For example, to describe 'Tuple2<String, String>' as a generic type, use 'new PravegaDeserializationSchema<>(new TypeHint<Tuple2<String, String>>(){}, serializer);'","messagePattern":"Could not create the type information for '(.+?)'\\. The most common reason is failure to infer the generic type information, due to Java's type erasure\\. In that case, please pass a 'TypeHint' instead of a class to describe the type\\. For example, to describe 'Tuple2<String, String>' as a generic type, use 'new PravegaDeserializationSchema<>\\(new TypeHint<Tuple2<String, String>>\\(\\)(.+?), serializer\\);'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/state/v2/StateSerializerReference.java","lineNumber":68,"sourceCode":"     * lazily.\n     */\n    @Nullable private final TypeInformation<T> typeInfo;\n\n    public StateSerializerReference(TypeInformation<T> typeInfo) {\n        super(null);\n        this.typeInfo = checkNotNull(typeInfo, \"type information must not be null\");\n    }\n\n    public StateSerializerReference(TypeSerializer<T> typeSerializer) {\n        super(checkNotNull(typeSerializer, \"type serializer must not be null\"));\n        this.typeInfo = null;\n    }\n\n    public StateSerializerReference(Class<T> clazz) {\n        try {\n            this.typeInfo = TypeExtractor.createTypeInfo(clazz);\n        } catch (Exception e) {\n            throw new RuntimeException(\n                    \"Could not create the type information for '\"\n                            + clazz.getName()\n                            + \"'. \"\n                            + \"The most common reason is failure to infer the generic type information, due to Java's type erasure. \"\n                            + \"In that case, please pass a 'TypeHint' instead of a class to describe the type. \"\n                            + \"For example, to describe 'Tuple2<String, String>' as a generic type, use \"\n                            + \"'new PravegaDeserializationSchema<>(new TypeHint<Tuple2<String, String>>(){}, serializer);'\",\n                    e);\n        }\n    }\n\n    public TypeInformation<T> getTypeInformation() {\n        return typeInfo;\n    }\n\n    /**\n     * Checks whether the serializer has been initialized. Serializer initialization is lazy, to\n     * allow parametrization of serializers with an {@link ExecutionConfig} via {@link","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/state/v2/StateSerializerReference.java#L50-L86","documentation":"StateSerializerReference (v2 support class) constructed with a Class<T> calls TypeExtractor.createTypeInfo(clazz) to derive TypeInformation. If that fails — most commonly because the class carries generic parameters that are erased at runtime — it throws a RuntimeException with guidance to use a TypeHint. This is the v2 analogue of the v1 StateDescriptor type-extraction failure.","triggerScenarios":"Building a v2 StateDescriptor or StateSerializerReference with the Class-based constructor where the class is generic (e.g., Tuple2.class, a generic POJO) so TypeExtractor cannot recover type parameters; a class whose type hierarchy contains unresolved type variables.","commonSituations":"DataStream v2 jobs using MapStateDescriptor(name, Class<UK>, Class<UV>) or ValueStateDescriptor(name, Class<T>) with a generic value type; migrating from v1 and hitting the same erasure wall via the v2 path.","solutions":["Use the TypeInformation-based constructor of the v2 descriptor, building TypeInformation via TypeInformation.of(new TypeHint<Tuple2<String,String>>(){}).","Pass a pre-built TypeSerializer to the StateSerializerReference if you already have one, bypassing extraction.","For non-generic value types, ensure the class is POJO-compliant (public, no-arg constructor) so createTypeInfo succeeds on the Class path."],"exampleFix":"// before\nnew ValueStateDescriptor<>(\"ev\", Tuple2.class); // v2 descriptor, erasure\n\n// after\nnew ValueStateDescriptor<>(\n    \"ev\",\n    TypeInformation.of(new TypeHint<Tuple2<String,String>>(){}));","handlingStrategy":"validation","validationCode":"Class<?> c = valueClass;\nif (c.getTypeParameters().length > 0) {\n    // use TypeInformation/TypeHint-based ctor instead\n    TypeInformation<T> ti = TypeInformation.of(new TypeHint<T>(){});\n    descriptor = new ValueStateDescriptor<>(name, ti);\n}","typeGuard":"static boolean isSafeForClassRef(Class<?> c) {\n    return c.getTypeParameters().length == 0;\n}","tryCatchPattern":"try {\n    ref = new StateSerializerReference<>(clazz);\n} catch (RuntimeException e) {\n    throw new IllegalArgumentException(\n        \"Provide a TypeInformation or TypeSerializer for \" + clazz.getName(), e);\n}","preventionTips":["Prefer StateSerializerReference(TypeInformation) or (TypeSerializer) constructors over the Class one for generic types.","Verify the class has no type parameters before using the Class path.","Unit-test v2 descriptor construction for every value type used."],"tags":["state-descriptor-v2","type-information","type-erasure","generics","type-extractor"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}