{"record":{"id":"0cc9e78d8deaf528","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-byte-t","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to Byte, typeDefine: ${typeDefine}","messagePattern":"Unsupported convert (.+?) to Byte, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":1238,"sourceCode":"\n    default short convertShort(String value) {\n        return Short.parseShort(value);\n    }\n\n    default byte convertByte(T typeDefine, Object value) throws UnsupportedOperationException {\n        if (value instanceof Byte) {\n            return (byte) value;\n        }\n        if (value instanceof Number) {\n            return convertByte(typeDefine, (Number) value);\n        }\n        if (value instanceof String) {\n            return convertByte(typeDefine, (String) value);\n        }\n        if (value instanceof Boolean) {\n            return convertByte(typeDefine, ((boolean) value));\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to Byte, typeDefine: \" + typeDefine);\n    }\n\n    default byte convertByte(T typeDefine, Number value) {\n        return convertByte(value);\n    }\n\n    default byte convertByte(T typeDefine, String value) {\n        return convertByte(value);\n    }\n\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;","sourceCodeStart":1220,"sourceCodeEnd":1256,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L1220-L1256","documentation":"Thrown by BasicDataConverter.convertByte(T typeDefine, Object value) when the value is neither a String nor a Boolean in this dispatch path (Number is handled via a separate overloaded branch). Byte conversion supports string parsing and boolean-to-0/1 mapping; any other class is rejected with the value class and type definition in the message.","triggerScenarios":"Calling convertByte(typeDefine, value) with byte[], LocalDate, Number subclass routed through this branch, Map or other objects while mapping a field to a TINYINT column.","commonSituations":"A source column typed BINARY/BYTES or DATE is mapped to TINYINT in the sink; nested/struct values reaching scalar converters; catalog definitions changed without updating field extraction.","solutions":["Decode or convert the value first (e.g. byte[0] for byte[], toEpochDay() for LocalDate, numeric parse for strings representing ints)","Correct the sink catalog type so it matches the actual source data type","Override convertByte(T typeDefine, Object value) in a custom converter to support the reported class"],"exampleFix":"// before\nbyte b = converter.convertByte(typeDefine, row.getField(0)); // byte[] throws\n// after\nObject v = row.getField(0);\nbyte b = (v instanceof byte[] && ((byte[]) v).length == 1) ? ((byte[]) v)[0] : converter.convertByte(typeDefine, 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() + \" is not convertible 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(typeDefine, value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Inconvertible value {} for TINYINT: {}\", value, e.getMessage());\n    b = 0;\n}","preventionTips":["Do not map BINARY/BYTES source columns to TINYINT; unwrap single-byte arrays yourself","Validate the catalog schema against source metadata before submission","Add converter tests for date and binary inputs"],"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"}