{"record":{"id":"8795432b7b9eb219","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-byte-879543","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":391,"sourceCode":"                        + \" to byte[], typeDefine: \"\n                        + typeDefine);\n    }\n\n    default byte[] convertBytes(T typeDefine, String value) {\n        return convertBytes(value);\n    }\n\n    default byte[] convertBytes(Object value) throws UnsupportedOperationException {\n        if (value instanceof byte[]) {\n            return (byte[]) value;\n        }\n        if (value instanceof ByteBuffer) {\n            return convertBytes((ByteBuffer) value);\n        }\n        if (value instanceof String) {\n            return convertBytes((String) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to byte[]\");\n    }\n\n    default byte[] convertBytes(ByteBuffer value) {\n        byte[] bytes = new byte[value.remaining()];\n        value.get(bytes);\n        return bytes;\n    }\n\n    default byte[] convertBytes(String value) {\n        return value.getBytes();\n    }\n\n    default LocalDateTime convertLocalDateTime(T typeDefine, Object value)\n            throws UnsupportedOperationException {\n        if (value instanceof LocalDateTime) {\n            return (LocalDateTime) value;\n        }","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L373-L409","documentation":"This parameterless convertBytes overload handles ByteBuffer and String only, then throws UnsupportedOperationException for any other class. Unlike error 85 it does not accept byte[] passthrough or include a typeDefine in the message. It signals a raw-type conversion attempt that the utility deliberately does not guess at.","triggerScenarios":"Calling convertBytes(Object value) directly with an Integer, char[], List<Byte>, InputStream, or similar that is neither ByteBuffer nor String.","commonSituations":"Reading bytes from a stream or a legacy buffer type (e.g. Netty ByteBuf) and passing them straight in; assuming the overload accepts byte[] like its typeDefine-aware sibling; char[] from password-style APIs.","solutions":["Copy the data into a ByteBuffer.wrap(...) or a String (with an explicit charset) before calling convertBytes.","Use the typeDefine-aware overload convertBytes(typeDefine, value) if your input is a byte[].","Override convertBytes in a converter subclass to add support for your buffer type (e.g. ByteBuf.array()).","Ensure the data is actually binary; otherwise use convertString and a STRING column."],"exampleFix":"// before\nconverter.convertBytes(nettyByteBuf);\n// after\nconverter.convertBytes(ByteBuffer.wrap(nettyByteBuf.array(), nettyByteBuf.arrayOffset(), nettyByteBuf.readableBytes()));","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof ByteBuffer) && !(value instanceof String)) {\n    throw new IllegalArgumentException(\"convertBytes(Object) accepts only ByteBuffer/String, got \" + value.getClass());\n}","typeGuard":"boolean isByteBufferOrString(Object v) { return v instanceof ByteBuffer || v instanceof String; }","tryCatchPattern":"try {\n    return converter.convertBytes(value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Raw bytes conversion failed: {}\", e.getMessage());\n    return null;\n}","preventionTips":["Prefer the typeDefine-aware overload for broader input support.","Wrap arrays with ByteBuffer.wrap before calling.","Copy non-JDK buffer types (ByteBuf) into ByteBuffer explicitly.","Do not pass char[] or List<Byte> expecting coercion."],"tags":["type-mismatch","bytes-conversion","seatunnel-api"],"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"}