apache/flink · error · InvalidTypesException
TypeInformation '{}' does not supply a mapping of TypeVariab
Error message
TypeInformation '{}' does not supply a mapping of TypeVariable '{}' to corresponding TypeInformation. Input type inference can only produce a result with this information. Please implement method 'TypeInformation.getGenericParameters()' for this. What it means
Thrown during input-based type inference when a TypeInfoFactory is involved and the input TypeInformation does not provide a mapping for a generic parameter via `getGenericParameters()`. The factory's defining type is parameterized, so the extractor iterates its type parameters and asks the input TypeInformation for a corresponding sub-type mapping — if that map is missing or returns null for a required parameter, inference fails.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java:1127
final List<Type> factoryHierarchy = new ArrayList<>(inputTypeHierarchy);
final TypeInfoFactory<?> factory = getClosestFactory(factoryHierarchy, inType);
if (factory != null) {
// the type that defines the factory is last in factory hierarchy
final Type factoryDefiningType = factoryHierarchy.get(factoryHierarchy.size() - 1);
// defining type has generics, the factory need to be asked for a mapping of subtypes to
// type information
if (factoryDefiningType instanceof ParameterizedType) {
final Type[] typeParams = typeToClass(factoryDefiningType).getTypeParameters();
final Type[] actualParams =
((ParameterizedType) factoryDefiningType).getActualTypeArguments();
// go thru all elements and search for type variables
for (int i = 0; i < actualParams.length; i++) {
final Map<String, TypeInformation<?>> componentInfo =
inTypeInfo.getGenericParameters();
final String typeParamName = typeParams[i].toString();
if (!componentInfo.containsKey(typeParamName)
|| componentInfo.get(typeParamName) == null) {
throw new InvalidTypesException(
"TypeInformation '"
+ inTypeInfo.getClass().getSimpleName()
+ "' does not supply a mapping of TypeVariable '"
+ typeParamName
+ "' to corresponding TypeInformation. "
+ "Input type inference can only produce a result with this information. "
+ "Please implement method 'TypeInformation.getGenericParameters()' for this.");
}
info =
createTypeInfoFromInput(
returnTypeVar,
factoryHierarchy,
actualParams[i],
componentInfo.get(typeParamName));
if (info != null) {
break;
}
}View on GitHub (pinned to 2f3c205e92)
Solutions
- Override `getGenericParameters()` in your custom TypeInformation subclass to return a map of type parameter name to TypeInformation
- Ensure the TypeInfoFactory's defining type and the input TypeInformation agree on parameter names
- If you don't control the TypeInformation class, provide the full TypeInformation explicitly instead of relying on input inference
Example fix
// before — custom TypeInformation without getGenericParameters()
public class MyTypeInfo<T> extends TypeInformation<MyType<T>> {
// getGenericParameters() not overridden -> returns empty map
}
// after — provide the mapping
@Override
public Map<String, TypeInformation<?>> getGenericParameters() {
return Collections.singletonMap("T", elementTypeInfo);
} Defensive patterns
Strategy: validation
Validate before calling
// Verify custom TypeInformation exposes generic parameters
TypeInformation<?> info = getMyTypeInfo();
Map<String, TypeInformation<?>> params = info.getGenericParameters();
if (params == null || params.isEmpty()) {
throw new IllegalStateException(
"Custom TypeInformation must override getGenericParameters() "
+ "when used with a TypeInfoFactory on a parameterized type");
} Prevention
- Override getGenericParameters() in custom TypeInformation subclasses used with TypeInfoFactory
- Document the expected type parameter names in your TypeInfoFactory
- Test the factory with both parameterized and raw type inputs
- Return a non-empty map from getGenericParameters() for all generic parameters
When it happens
Trigger: A custom TypeInfoFactory is registered on a type whose generic parameters need to be resolved from the input. The input TypeInformation's `getGenericParameters()` method (which defaults to an empty map in the base class) does not contain the required type parameter name. This happens with custom TypeInformation implementations that don't override getGenericParameters().
Common situations: Writing a custom TypeInfoFactory for a parameterized type and a corresponding custom TypeInformation that doesn't implement getGenericParameters(). Using a third-party type with a TypeInfoFactory annotation where the type info class hasn't overridden the generic parameters mapping. Custom PojoTypeInfo or similar subclasses that need to expose their generic parameter mappings.
Related errors
- TypeInfoFactory returned invalid TypeInformation 'null'
- Type extraction is not possible on Either type as it does no
- Type extraction is not possible on Either type as it does no
- Cannot extract the type argument with index {} because the t
- The given type {} is not a parameterized type.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/346ef5555e8047eb.
Report an issue: GitHub.