{"record":{"id":"c1e07c8f0d3e4a98","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-integer","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to Integer, typeDefine: ${typeDefine}","messagePattern":"Unsupported convert (.+?) to Integer, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":1089,"sourceCode":"        if (value instanceof String) {\n            return convertInt(typeDefine, (String) value);\n        }\n        if (value instanceof Time) {\n            return convertInt(typeDefine, (Time) value);\n        }\n        if (value instanceof LocalTime) {\n            return convertInt(typeDefine, (LocalTime) value);\n        }\n        if (value instanceof Date) {\n            return convertInt(typeDefine, (Date) value);\n        }\n        if (value instanceof LocalDate) {\n            return convertInt(typeDefine, (LocalDate) value);\n        }\n        if (value instanceof LocalDateTime) {\n            return convertInt(typeDefine, (LocalDateTime) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \"\n                        + value.getClass()\n                        + \" to Integer, typeDefine: \"\n                        + typeDefine);\n    }\n\n    default int convertInt(T typeDefine, Number value) {\n        return convertInt(value);\n    }\n\n    default int convertInt(T typeDefine, String value) {\n        return convertInt(value);\n    }\n\n    default int convertInt(T typeDefine, Time value) {\n        return convertInt(value);\n    }\n","sourceCodeStart":1071,"sourceCodeEnd":1107,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L1071-L1107","documentation":"Thrown by BasicDataConverter.convertInt(T typeDefine, Object value) when the value is neither a LocalDate nor a LocalDateTime. Integer conversion supports date values (as days/seconds) and, via other branches, Number/String; any other class triggers this exception with the value class and type definition in the message.","triggerScenarios":"Calling convertInt(typeDefine, value) with a String, byte[], Boolean, java.util.Date or nested object while mapping a field to an INT column.","commonSituations":"Source emits numeric strings or booleans but the sink schema says INT; column type in the target table changed from DATE/TIMESTAMP to INT; a custom connector passes raw objects (e.g. byte-encoded ints) without unwrapping them first.","solutions":["Unwrap/convert the value before conversion (Integer.parseInt for numeric strings, boolean ? 1 : 0, ByteBuffer/byte[] decode)","Correct the catalog type: use DATE/TIMESTAMP for date values or STRING/VARCHAR for textual values instead of forcing INT","Override convertInt(T typeDefine, Object value) in a custom converter to support the reported class"],"exampleFix":"// before\nint i = converter.convertInt(typeDefine, row.getField(0)); // String throws\n// after\nObject v = row.getField(0);\nint i = (v instanceof String) ? Integer.parseInt((String) v) : converter.convertInt(typeDefine, v);","handlingStrategy":"type-guard","validationCode":"Object v = row.getField(0);\nif (!(v instanceof Number) && !(v instanceof String) && !(v instanceof LocalDate) && !(v instanceof LocalDateTime)) {\n    throw new IllegalArgumentException(\"Value \" + v.getClass() + \" is not convertible to INT\");\n}","typeGuard":"static boolean isIntConvertible(Object v) {\n    return v instanceof Number || v instanceof String || v instanceof LocalDate || v instanceof LocalDateTime;\n}","tryCatchPattern":"try {\n    i = converter.convertInt(typeDefine, value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Inconvertible value {} for INT: {}\", value, e.getMessage());\n    i = 0;\n}","preventionTips":["Confirm the sink catalog type matches the extracted field type before job submission","Convert byte[]/Boolean values explicitly in a transform step","Cover each field type in converter unit tests"],"tags":["java","type-conversion","unsupported-operation"],"backgroundTag":"type-mismatch","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"}