{"record":{"id":"2c36db27ea90e484","repo":"apache/seatunnel","slug":"unable-to-convert-to-localdatetime-from-unexpected","errorCode":null,"errorMessage":"Unable to convert to LocalDateTime from unexpected value '' of type ","messagePattern":"Unable to convert to LocalDateTime from unexpected value '' of type ","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/debezium/row/SeaTunnelRowDebeziumDeserializationConverters.java","lineNumber":575,"sourceCode":"        LocalDate localDate = LocalDate.ofEpochDay(date);\n        LocalTime localTime = LocalTime.ofNanoOfDay(nanoOfDay);\n        return LocalDateTime.of(localDate, localTime);\n    }\n\n    private static DebeziumDeserializationConverter convertToLocalTimeZoneTimestamp(\n            ZoneId serverTimeZone) {\n        return new DebeziumDeserializationConverter() {\n            private static final long serialVersionUID = 1L;\n\n            @Override\n            public Object convert(Object dbzObj, Schema schema) {\n                if (dbzObj instanceof String) {\n                    String str = (String) dbzObj;\n                    // TIMESTAMP type is encoded in string type\n                    Instant instant = Instant.parse(str);\n                    return LocalDateTime.ofInstant(instant, serverTimeZone);\n                }\n                throw new IllegalArgumentException(\n                        \"Unable to convert to LocalDateTime from unexpected value '\"\n                                + dbzObj\n                                + \"' of type \"\n                                + dbzObj.getClass().getName());\n            }\n        };\n    }\n\n    private static DebeziumDeserializationConverter convertToString() {\n        return new DebeziumDeserializationConverter() {\n            private static final long serialVersionUID = 1L;\n\n            @Override\n            public Object convert(Object dbzObj, Schema schema) {\n                if (dbzObj == null) {\n                    return null;\n                }\n","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/debezium/row/SeaTunnelRowDebeziumDeserializationConverters.java#L557-L593","documentation":"The TIMESTAMP converter in SeaTunnelRowDebeziumDeserializationConverters accepts numeric epoch values or ISO-8601 instant strings. Any other object type (e.g. java.util.Date, Timestamp in unexpected form) reaches the IllegalArgumentException 'Unable to convert to LocalDateTime from unexpected value ... of type ...', which reports the value and its Java class.","triggerScenarios":"convert() for TIMESTAMP receives a dbzObj that is neither Long/Integer epoch micros nor a parseable String Instant — e.g. a java.sql.Timestamp, java.util.Date, or an unparseable string.","commonSituations":"Database driver/Debezium converter returning Date-like objects instead of the expected epoch long or ISO string; malformed timestamp strings (not Instant.parse-able) such as '2024-01-01 10:00:00' without T/Z.","solutions":["Check the class name in the message and add/enable the appropriate value converter (e.g. TimestampConverter) so Debezium emits epoch micros or ISO strings.","Pre-normalize strings to ISO-8601 Instant format (e.g. '2024-01-01T10:00:00Z') via a transform or source-side formatting.","Fix invalid source timestamp values that fail Instant.parse, or map the column to STRING in the schema and parse downstream."],"exampleFix":"// before\n// value '2024-01-01 10:00:00' (no T/Z) -> IllegalArgumentException\n// after\n// value '2024-01-01T10:00:00Z' parses as Instant and converts","handlingStrategy":"type-guard","validationCode":"// Java\nstatic boolean isConvertibleToTimestamp(Object v) {\n    return v instanceof Number\n        || (v instanceof String && canParseInstant((String) v));\n}\nstatic boolean canParseInstant(String s) {\n    try { Instant.parse(s); return true; } catch (Exception e) { return false; }\n}","typeGuard":"if (!(dbzObj instanceof Number) && !(dbzObj instanceof String)) {\n    log.warn(\"TIMESTAMP value of type {} will be rejected; convert to epoch micros or ISO string first\", dbzObj.getClass());\n}","tryCatchPattern":"try {\n    ldt = timestampConverter.convert(dbzObj);\n} catch (IllegalArgumentException e) {\n    log.warn(\"bad TIMESTAMP value {} ({}), mapping to null\", dbzObj, dbzObj.getClass(), e);\n    ldt = null;\n}","preventionTips":["Ensure Debezium's timestamp converters emit epoch micros or ISO-8601 Instant strings","Store timestamps without driver-specific formats ('2024-01-01 10:00:00' will not parse as an Instant)","Validate a sample of CDC records against the expected converter types during pipeline bring-up"],"tags":["cdc","datetime","type-mismatch","deserialization"],"backgroundTag":"invalid-argument-format","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}