{"record":{"id":"d4de62b2b44f9eb4","repo":"apache/flink","slug":"e-getmessage-d4de62","errorCode":null,"errorMessage":"{e.getMessage()}","messagePattern":"\\{e\\.getMessage\\(\\)\\}","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-connector-datagen/src/main/java/org/apache/flink/connector/datagen/functions/IndexLookupGeneratorFunction.java","lineNumber":173,"sourceCode":"                    \"Failed to deserialize an element from the source. \"\n                            + \"If you are using user-defined serialization (Value and Writable \"\n                            + \"types), check the serialization functions.\\nSerializer is \"\n                            + serializer,\n                    e);\n        }\n    }\n\n    private void buildLookup() throws IOException {\n        for (long i = 0; i < numElements; i++) {\n            lookupMap.put(i, tryDeserialize());\n        }\n    }\n\n    private void trySerialize(Iterable<OUT> elements) {\n        try {\n            serializeElements(elements);\n        } catch (IOException e) {\n            throw new RuntimeException(e.getMessage(), e);\n        }\n    }\n}\n","sourceCodeStart":155,"sourceCodeEnd":177,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-connector-datagen/src/main/java/org/apache/flink/connector/datagen/functions/IndexLookupGeneratorFunction.java#L155-L177","documentation":"Thrown by the private trySerialize method in IndexLookupGeneratorFunction when serializing user-supplied elements fails during construction. The serializeElements IOException is wrapped as RuntimeException(e.getMessage(), e) because the constructor cannot declare checked exceptions. This mirrors the pattern in FromElementsGeneratorFunction.","triggerScenarios":"Constructing new IndexLookupGeneratorFunction<>(typeInfo, elements) where the TypeSerializer cannot serialize one or more elements. The underlying serializeElements wraps the original exception as IOException, which trySerialize re-wraps as RuntimeException.","commonSituations":"POJO fields that are not serializable; custom Value/Writable types with broken write() methods; TypeInformation mismatch with actual element types; elements containing non-serializable nested objects.","solutions":["Examine the wrapped cause chain — the RuntimeException wraps an IOException which wraps the original failure.","Ensure all element fields are serializable by the Flink TypeSerializer for the declared TypeInformation.","Test the TypeSerializer in isolation to find the failing element.","For custom Value or Writable types, verify write/readFields round-trip correctly."],"exampleFix":"// before: fails if CustomType.write() is broken\nnew IndexLookupGeneratorFunction<>(TypeInformation.of(CustomType.class), items);\n\n// after: fix the serializer and verify round-trip\nTypeSerializer<CustomType> ser = TypeInformation.of(CustomType.class).createSerializer(new SerializerConfig());\n// unit test: serialize then deserialize each element\nnew IndexLookupGeneratorFunction<>(TypeInformation.of(CustomType.class), items);","handlingStrategy":"validation","validationCode":"// Validate serialization before constructing IndexLookupGeneratorFunction\nTypeSerializer<OUT> serializer = typeInfo.createSerializer(config.getSerializerConfig());\nDataOutputViewStreamWrapper wrapper =\n    new DataOutputViewStreamWrapper(new ByteArrayOutputStream());\nfor (OUT element : elements) {\n    serializer.serialize(element, wrapper);\n}","typeGuard":null,"tryCatchPattern":"try {\n    new IndexLookupGeneratorFunction<>(typeInfo, elements);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof IOException) {\n        // inspect e.getCause().getCause() for root serialization error\n    }\n    throw e;\n}","preventionTips":["Test TypeSerializer round-trip for custom types before construction.","Ensure POJO fields are serializable.","Verify Value/Writable write() correctness."],"tags":["datagen","serialization","index-lookup","constructor"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}