{"record":{"id":"17c4d38b7139310b","repo":"apache/flink","slug":"value-type-expected","errorCode":null,"errorMessage":"Value type expected.","messagePattern":"Value 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":1656,"sourceCode":"                }\n\n                if (component instanceof TypeVariable<?>) {\n                    component = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) component);\n                    if (component instanceof TypeVariable) {\n                        return;\n                    }\n                }\n\n                validateInfo(\n                        typeHierarchy,\n                        component,\n                        ((ObjectArrayTypeInfo<?, ?>) typeInfo).getComponentInfo());\n            }\n            // check for value\n            else if (typeInfo instanceof ValueTypeInfo<?>) {\n                // check if value at all\n                if (!(type instanceof Class<?> && Value.class.isAssignableFrom((Class<?>) type))) {\n                    throw new InvalidTypesException(\"Value type expected.\");\n                }\n\n                TypeInformation<?> actual;\n                // check value type contents\n                if (!typeInfo.equals(\n                        actual = ValueTypeInfo.getValueTypeInfo((Class<? extends Value>) type))) {\n                    throw new InvalidTypesException(\n                            \"Value type '\" + typeInfo + \"' expected but was '\" + actual + \"'.\");\n                }\n            }\n            // check for POJO\n            else if (typeInfo instanceof PojoTypeInfo) {\n                Class<?> clazz = null;\n                if (!(isClassType(type)\n                        && ((PojoTypeInfo<?>) typeInfo).getTypeClass()\n                                == (clazz = typeToClass(type)))) {\n                    throw new InvalidTypesException(\n                            \"POJO type '\"","sourceCodeStart":1638,"sourceCodeEnd":1674,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java#L1638-L1674","documentation":"Thrown by TypeExtractor.validateInfo when a ValueTypeInfo is expected but the extracted Java type is not a Class that extends org.apache.flink.types.Value. This means the type extractor expected a Flink Value type (custom serializable type implementing Value) but the reflected type was something else (a plain POJO, a primitive, etc.).","triggerScenarios":"Called during validateInfo when TypeInformation is a ValueTypeInfo but the reflected type is not a Class assignable to Value.class. This occurs when a UDF declares its type as a Value subclass (e.g., IntValue, StringValue, or a custom Value) but the actual generic type argument resolves to a different class, a TypeVariable, or a raw type.","commonSituations":"Declaring a function with a Value type but using a different type in the actual implementation. Mixing Flink Value wrapper types (IntValue, StringValue) with their Java primitive equivalents (int, String). Custom Value subclasses used incorrectly in generic hierarchies where erasure hides the actual type.","solutions":["Ensure the UDF signature uses the exact Value subclass (e.g., IntValue, not int).","Provide explicit TypeInformation via .returns(ValueTypeInfo.of(MyValue.class)) or createTypeInfo.","If the type is genuinely not a Value type, use the correct TypeInformation (e.g., BasicTypeInfo for primitives).","Avoid mixing Value wrappers with their primitive counterparts in generic positions."],"exampleFix":"// before\npublic IntValue map(Integer v) { return new IntValue(v); } // mismatch on generic\n// after\npublic IntValue map(Integer v) { return new IntValue(v); }\n.returns(ValueTypeInfo.of(IntValue.class))","handlingStrategy":"validation","validationCode":"// Verify the type extends Value before extraction\nClass<?> clazz = typeToClass(type);\nif (!Value.class.isAssignableFrom(clazz)) {\n    // not a Value type; use appropriate TypeInformation\n    ti = TypeInformation.of(clazz);\n}","typeGuard":"static boolean isValueType(Type t) {\n    return t instanceof Class<?> && Value.class.isAssignableFrom((Class<?>) t);\n}","tryCatchPattern":"try {\n    TypeInformation<?> ti = TypeExtractor.createTypeInfo(myFunction.getClass());\n} catch (InvalidTypesException e) {\n    ti = ValueTypeInfo.of(MyValue.class);\n}","preventionTips":["Ensure UDF signatures use the exact Value subclass (e.g., IntValue).","Do not mix Flink Value wrappers with Java primitives in generic positions.","Provide explicit .returns(ValueTypeInfo.of(...)) hints."],"tags":["type-extraction","value-type","typeinfo","udf"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}