{"record":{"id":"1b69715d4f62baa9","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-byte-1b6971","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to Byte","messagePattern":"Unsupported convert (.+?) to Byte","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":1267,"sourceCode":"\n    default byte convertByte(T typeDefine, boolean value) {\n        return convertByte(value);\n    }\n\n    default byte convertByte(Object value) throws UnsupportedOperationException {\n        if (value instanceof Byte) {\n            return (byte) value;\n        }\n        if (value instanceof Number) {\n            return convertByte((Number) value);\n        }\n        if (value instanceof String) {\n            return convertByte((String) value);\n        }\n        if (value instanceof Boolean) {\n            return convertByte(((boolean) value));\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to Byte\");\n    }\n\n    default byte convertByte(Number value) {\n        return value.byteValue();\n    }\n\n    default byte convertByte(String value) {\n        return Byte.parseByte(value);\n    }\n\n    default byte convertByte(boolean value) {\n        return value ? (byte) 1 : (byte) 0;\n    }\n\n    default boolean convertBoolean(T typeDefine, Object value)\n            throws UnsupportedOperationException {\n        if (value instanceof Boolean) {","sourceCodeStart":1249,"sourceCodeEnd":1285,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L1249-L1285","documentation":"Thrown by BasicDataConverter.convertByte(Object value) when the value is neither a String nor a Boolean (numeric handling lives in the convertByte(Number) overload). The message reports the class of the value that could not be converted to a byte.","triggerScenarios":"Calling the convertByte(Object) overload with byte[], LocalDate, Number (if not routed to the Number overload), or arbitrary objects while expecting a TINYINT value.","commonSituations":"Generic Object-row transforms feeding scalar converters; schema drift after table migrations; direct use of the convenience overload with unconverted values in custom connector code.","solutions":["Pre-convert the value to String/Boolean/Number before calling convertByte","Fix the catalog schema so the declared type matches the data actually produced by the source","Override convertByte(Object) in a custom converter to add the missing class branch"],"exampleFix":"// before\nbyte b = converter.convertByte(row.getField(0)); // LocalDate throws\n// after\nObject v = row.getField(0);\nbyte b = (v instanceof LocalDate) ? (byte) ((LocalDate) v).toEpochDay() : converter.convertByte(v);","handlingStrategy":"type-guard","validationCode":"Object v = row.getField(0);\nif (!(v instanceof Number) && !(v instanceof String) && !(v instanceof Boolean)) {\n    throw new IllegalArgumentException(\"Value \" + v.getClass() + \" cannot be converted to byte\");\n}","typeGuard":"static boolean isByteConvertible(Object v) {\n    return v instanceof Number || v instanceof String || v instanceof Boolean;\n}","tryCatchPattern":"try {\n    b = converter.convertByte(value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Cannot convert {} to byte\", value.getClass());\n    b = 0;\n}","preventionTips":["Use convertByte(Number)/convertByte(String) overloads directly when types are known","Convert dates/binary values explicitly before scalar conversion","Keep a schema-mapping test that exercises every TINYINT field"],"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-23T08:17:48.524Z"}