apache/flink · error · InvalidTypesException

Unknown Error. Type is null.

Error message

Unknown Error. Type is null.

What it means

Thrown at the start of `validateInfo` when the `type` argument (extracted from the function's signature via reflection) is null. This indicates an internal extraction failure where getParameterType returned null instead of throwing earlier, which should not happen under normal operation. It is a defensive guard against an unexpected internal state.

Source

Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java:1490

        Type inType;
        try {
            inType = getParameterType(baseClass, typeHierarchy, clazz, inputParamPos);
        } catch (InvalidTypesException e) {
            return; // skip input validation e.g. for raw types
        }

        try {
            validateInfo(typeHierarchy, inType, inTypeInfo);
        } catch (InvalidTypesException e) {
            throw new InvalidTypesException("Input mismatch: " + e.getMessage(), e);
        }
    }

    @SuppressWarnings("unchecked")
    private static void validateInfo(
            List<Type> typeHierarchy, Type type, TypeInformation<?> typeInfo) {
        if (type == null) {
            throw new InvalidTypesException("Unknown Error. Type is null.");
        }

        if (typeInfo == null) {
            throw new InvalidTypesException("Unknown Error. TypeInformation is null.");
        }

        if (!(type instanceof TypeVariable<?>)) {
            // check for Java Basic Types
            if (typeInfo instanceof BasicTypeInfo) {

                TypeInformation<?> actual;
                // check if basic type at all
                if (!(type instanceof Class<?>)
                        || (actual = BasicTypeInfo.getInfoFor((Class<?>) type)) == null) {
                    throw new InvalidTypesException("Basic type expected.");
                }
                // check if correct basic type
                if (!typeInfo.equals(actual)) {

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Implement ResultTypeQueryable to bypass reflection-based type extraction entirely
  2. Simplify the function's class hierarchy to avoid confusing the extractor
  3. Provide TypeInformation explicitly via `.returns(...)` or `.type(...)`
  4. Report as a Flink bug if it occurs with a straightforward function implementation
Defensive patterns

Strategy: fallback

Try / catch

try {
    resultStream = inputStream.map(myFunction);
} catch (InvalidTypesException e) {
    if (e.getMessage().contains("Type is null")) {
        // Internal extraction failure — bypass with explicit type
        resultStream = inputStream.map(myFunction)
            .returns(TypeInformation.of(MyOutputType.class));
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: During input type validation, the Type object extracted by `getParameterType` from the function class hierarchy is null. This is typically an internal bug or an edge case in the extraction logic where a type could not be determined but null was returned instead of an exception being thrown.

Common situations: Rare internal extraction failure during input validation. Usually preceded by a partial type extraction that silently returned null. May occur with unusual class hierarchies or synthetic classes that confuse the reflection-based extractor.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/40586a52e0c620de. Report an issue: GitHub.