{"record":{"id":"a6a2a63b39d52951","repo":"apache/flink","slug":"basic-type-expected","errorCode":null,"errorMessage":"Basic type expected.","messagePattern":"Basic type expected\\.","errorType":"exception","errorClass":"InvalidTypesException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java","lineNumber":1505,"sourceCode":"    private static void validateInfo(\n            List<Type> typeHierarchy, Type type, TypeInformation<?> typeInfo) {\n        if (type == null) {\n            throw new InvalidTypesException(\"Unknown Error. Type is null.\");\n        }\n\n        if (typeInfo == null) {\n            throw new InvalidTypesException(\"Unknown Error. TypeInformation is null.\");\n        }\n\n        if (!(type instanceof TypeVariable<?>)) {\n            // check for Java Basic Types\n            if (typeInfo instanceof BasicTypeInfo) {\n\n                TypeInformation<?> actual;\n                // check if basic type at all\n                if (!(type instanceof Class<?>)\n                        || (actual = BasicTypeInfo.getInfoFor((Class<?>) type)) == null) {\n                    throw new InvalidTypesException(\"Basic type expected.\");\n                }\n                // check if correct basic type\n                if (!typeInfo.equals(actual)) {\n                    throw new InvalidTypesException(\n                            \"Basic type '\" + typeInfo + \"' expected but was '\" + actual + \"'.\");\n                }\n\n            }\n            // check for Java SQL time types\n            else if (typeInfo instanceof SqlTimeTypeInfo) {\n\n                TypeInformation<?> actual;\n                // check if SQL time type at all\n                if (!(type instanceof Class<?>)\n                        || (actual = SqlTimeTypeInfo.getInfoFor((Class<?>) type)) == null) {\n                    throw new InvalidTypesException(\"SQL time type expected.\");\n                }\n                // check if correct SQL time type","sourceCodeStart":1487,"sourceCodeEnd":1523,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java#L1487-L1523","documentation":"Thrown during input type validation when the TypeInformation is a BasicTypeInfo (wrapping a Java primitive wrapper like Integer, String, Double, etc.) but the reflected Type is not a recognized basic type. `BasicTypeInfo.getInfoFor()` returns null for the class, meaning it is not one of the supported basic types (String, Boolean, Byte, Short, Integer, Long, Float, Double, Character, Void, BigDecimal, BigInteger, Date, etc.).","triggerScenarios":"A function declares BasicTypeInfo as its input type information but the actual reflected type from the function signature is a non-basic class. For example, the DataStream expects a basic type but the function signature specifies a custom POJO or enum.","commonSituations":"Connecting a function that expects `MapFunction<Integer, X>` to a stream of custom POJOs. Using a non-standard type where a basic Java type is expected. Mismatches between the TypeInformation registered on the DataStream and the function's declared input type.","solutions":["Ensure the function's input type parameter is a recognized Java basic type (String, Integer, Long, Double, etc.)","Transform the stream with a prior map to convert to the correct basic type","Fix the function signature to use the correct input type matching the stream"],"exampleFix":"// before — function expects basic type, stream carries POJO\nDataStream<MyEvent> events = ...;\nevents.map(new MapFunction<Integer, String>() { ... });\n\n// after — align types\nevents.map(event -> event.getCount())  // extract basic type first\n      .map(new MapFunction<Integer, String>() { ... });","handlingStrategy":"validation","validationCode":"// Verify the stream's element type is a recognized Flink basic type\nTypeInformation<?> elementType = stream.getType();\nif (elementType instanceof BasicTypeInfo) {\n    // OK — stream carries a basic type\n} else {\n    throw new IllegalStateException(\n        \"Expected a basic type stream but got: \" + elementType);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the function's input type parameter is a recognized Java basic type","Check Types.BASIC_TYPES or BasicTypeInfo for the list of supported basic types","Add explicit type conversion maps when connecting streams of different element types","Use TypeInformation.of(ExpectedType.class) to verify expected types before connecting"],"tags":["type-validation","basic-type","type-mismatch","reflection"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}