apache/flink · error · InvalidTypesException
TypeInfo annotation does not specify a valid TypeInfoFactory
Error message
TypeInfo annotation does not specify a valid TypeInfoFactory.
What it means
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.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java:1746
/**
* Returns the type information factory for a type using the factory registry or annotations.
*/
@Internal
@SuppressWarnings("unchecked")
public static <OUT> TypeInfoFactory<OUT> getTypeInfoFactory(Type t) {
final Class<?> factoryClass;
if (registeredTypeInfoFactories.containsKey(t)) {
factoryClass = registeredTypeInfoFactories.get(t);
} else {
if (!isClassType(t) || !typeToClass(t).isAnnotationPresent(TypeInfo.class)) {
return null;
}
final TypeInfo typeInfoAnnotation = typeToClass(t).getAnnotation(TypeInfo.class);
factoryClass = typeInfoAnnotation.value();
// check for valid factory class
if (!TypeInfoFactory.class.isAssignableFrom(factoryClass)) {
throw new InvalidTypesException(
"TypeInfo annotation does not specify a valid TypeInfoFactory.");
}
}
// instantiate
return (TypeInfoFactory<OUT>) InstantiationUtil.instantiate(factoryClass);
}
/** Returns the type information factory for an annotated field. */
@Internal
@SuppressWarnings("unchecked")
public static <OUT> TypeInfoFactory<OUT> getTypeInfoFactory(Field field) {
if (!isClassType(field.getType()) || !field.isAnnotationPresent(TypeInfo.class)) {
return null;
}
Class<?> factoryClass = field.getAnnotation(TypeInfo.class).value();
// check for valid factory classView on GitHub (pinned to 2f3c205e92)
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.
Example fix
// before
@TypeInfo(MyInvalidFactory.class)
public class MyType { ... }
// MyInvalidFactory does NOT extend TypeInfoFactory
// after
@TypeInfo(MyValidFactory.class)
public class MyType { ... }
public class MyValidFactory extends TypeInfoFactory<MyType> {
public TypeInformation<MyType> createTypeInfo(Type t, Map<String, TypeInformation<?>> m) {
return PojoTypeInfo.of(MyType.class);
}
} Defensive patterns
Strategy: validation
Validate before calling
// Before using @TypeInfo annotation, verify the factory class
TypeInfo annotation = typeToClass(t).getAnnotation(TypeInfo.class);
if (annotation != null) {
Class<?> factoryClass = annotation.value();
if (!TypeInfoFactory.class.isAssignableFrom(factoryClass)) {
// fix annotation to reference a valid TypeInfoFactory
}
} Type guard
static boolean isValidTypeInfoFactory(Class<?> factoryClass) {
return TypeInfoFactory.class.isAssignableFrom(factoryClass);
} Try / catch
try {
TypeInfoFactory<?> factory = TypeExtractor.getTypeInfoFactory(t);
} catch (InvalidTypesException e) {
// remove or fix the @TypeInfo annotation
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No cluster id was specified. Please specify a cluster to whi
- The configuration directory '{}', specified in the '{}' envi
- The configuration directory was not specified. Please specif
- No valid command-line found.
- Bad syntax for classpath: {}
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/5bce35d05b28065c.
Report an issue: GitHub.