{"record":{"id":"5bce35d05b28065c","repo":"apache/flink","slug":"typeinfo-annotation-does-not-specify-a-valid-typei","errorCode":null,"errorMessage":"TypeInfo annotation does not specify a valid TypeInfoFactory.","messagePattern":"TypeInfo annotation does not specify a valid TypeInfoFactory\\.","errorType":"validation","errorClass":"InvalidTypesException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java","lineNumber":1746,"sourceCode":"\n    /**\n     * Returns the type information factory for a type using the factory registry or annotations.\n     */\n    @Internal\n    @SuppressWarnings(\"unchecked\")\n    public static <OUT> TypeInfoFactory<OUT> getTypeInfoFactory(Type t) {\n        final Class<?> factoryClass;\n        if (registeredTypeInfoFactories.containsKey(t)) {\n            factoryClass = registeredTypeInfoFactories.get(t);\n        } else {\n            if (!isClassType(t) || !typeToClass(t).isAnnotationPresent(TypeInfo.class)) {\n                return null;\n            }\n            final TypeInfo typeInfoAnnotation = typeToClass(t).getAnnotation(TypeInfo.class);\n            factoryClass = typeInfoAnnotation.value();\n            // check for valid factory class\n            if (!TypeInfoFactory.class.isAssignableFrom(factoryClass)) {\n                throw new InvalidTypesException(\n                        \"TypeInfo annotation does not specify a valid TypeInfoFactory.\");\n            }\n        }\n\n        // instantiate\n        return (TypeInfoFactory<OUT>) InstantiationUtil.instantiate(factoryClass);\n    }\n\n    /** Returns the type information factory for an annotated field. */\n    @Internal\n    @SuppressWarnings(\"unchecked\")\n    public static <OUT> TypeInfoFactory<OUT> getTypeInfoFactory(Field field) {\n        if (!isClassType(field.getType()) || !field.isAnnotationPresent(TypeInfo.class)) {\n            return null;\n        }\n\n        Class<?> factoryClass = field.getAnnotation(TypeInfo.class).value();\n        // check for valid factory class","sourceCodeStart":1728,"sourceCodeEnd":1764,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java#L1728-L1764","documentation":"Thrown by TypeExtractor.getTypeInfoFactory(Type t) when a class or type is annotated with @TypeInfo but the annotation's value() does not reference a class that extends TypeInfoFactory. This means the custom type info factory annotation is misconfigured — it points to a class that is not a valid TypeInfoFactory implementation.","triggerScenarios":"Called during createTypeInfoFromFactory when resolving the @TypeInfo annotation on a type/class. The annotation is present, its value() is read as a Class, but TypeInfoFactory.class.isAssignableFrom(factoryClass) returns false. This happens when the annotation references a class that does not implement/extend TypeInfoFactory.","commonSituations":"Creating a custom TypeInfoFactory but forgetting to extend TypeInfoFactory. Typo or wrong class name in the @TypeInfo annotation value. Using a legacy or renamed factory class that no longer extends TypeInfoFactory after a Flink version upgrade.","solutions":["Ensure the class referenced in @TypeInfo(MyFactory.class) extends TypeInfoFactory<YourType>.","Fix any typo in the factory class reference.","If upgrading Flink versions, check that TypeInfoFactory's API hasn't changed in a way that breaks your factory.","Compile-check that the factory class implements all required abstract methods of TypeInfoFactory."],"exampleFix":"// before\n@TypeInfo(MyInvalidFactory.class)\npublic class MyType { ... }\n// MyInvalidFactory does NOT extend TypeInfoFactory\n\n// after\n@TypeInfo(MyValidFactory.class)\npublic class MyType { ... }\npublic class MyValidFactory extends TypeInfoFactory<MyType> {\n    public TypeInformation<MyType> createTypeInfo(Type t, Map<String, TypeInformation<?>> m) {\n        return PojoTypeInfo.of(MyType.class);\n    }\n}","handlingStrategy":"validation","validationCode":"// Before using @TypeInfo annotation, verify the factory class\nTypeInfo annotation = typeToClass(t).getAnnotation(TypeInfo.class);\nif (annotation != null) {\n    Class<?> factoryClass = annotation.value();\n    if (!TypeInfoFactory.class.isAssignableFrom(factoryClass)) {\n        // fix annotation to reference a valid TypeInfoFactory\n    }\n}","typeGuard":"static boolean isValidTypeInfoFactory(Class<?> factoryClass) {\n    return TypeInfoFactory.class.isAssignableFrom(factoryClass);\n}","tryCatchPattern":"try {\n    TypeInfoFactory<?> factory = TypeExtractor.getTypeInfoFactory(t);\n} catch (InvalidTypesException e) {\n    // remove or fix the @TypeInfo annotation\n}","preventionTips":["Always extend TypeInfoFactory<YourType> when creating custom factories.","Compile-check that the factory class implements all abstract methods.","Review @TypeInfo annotation values after Flink version upgrades."],"tags":["type-extraction","typeinfo-annotation","typeinfofactory","configuration"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}