apache/seatunnel · error · UnsupportedOperationException
Unsupported convert ${value.getClass()} to byte[], typeDefin
Error message
Unsupported convert ${value.getClass()} to byte[], typeDefine: ${typeDefine} What it means
The typeDefine-aware convertBytes overload supports byte[], ByteBuffer, and String inputs; anything else triggers this UnsupportedOperationException. The typeDefine gives context about the expected BytesType column. It fires when a value routed to BYTES conversion is none of the three supported classes.
Source
Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java:370
default String convertString(LocalTime value) {
return value.toString();
}
default String convertString(LocalDateTime value) {
return value.toString();
}
default byte[] convertBytes(T typeDefine, Object value) throws UnsupportedOperationException {
if (value instanceof byte[]) {
return (byte[]) value;
}
if (value instanceof ByteBuffer) {
return convertBytes((ByteBuffer) value);
}
if (value instanceof String) {
return convertBytes(typeDefine, (String) value);
}
throw new UnsupportedOperationException(
"Unsupported convert "
+ value.getClass()
+ " to byte[], typeDefine: "
+ typeDefine);
}
default byte[] convertBytes(T typeDefine, String value) {
return convertBytes(value);
}
default byte[] convertBytes(Object value) throws UnsupportedOperationException {
if (value instanceof byte[]) {
return (byte[]) value;
}
if (value instanceof ByteBuffer) {
return convertBytes((ByteBuffer) value);
}
if (value instanceof String) {View on GitHub (pinned to cf67b549a7)
Solutions
- Convert the value to byte[] yourself first (e.g. ByteString.toByteArray(), or serialize the POJO with an agreed format).
- If the value is a wrapper like protobuf ByteString, call its toByteArray() before conversion.
- Override convertBytes in your converter to handle the offending class.
- Check the schema: if the data is really an integer or string, use the appropriate SqlType instead of BYTES.
Example fix
// before converter.convertBytes(bytesType, protoByteString); // after converter.convertBytes(bytesType, protoByteString.toByteArray());
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(value instanceof byte[]) && !(value instanceof ByteBuffer) && !(value instanceof String)) {
throw new IllegalArgumentException("convertBytes expects byte[]/ByteBuffer/String, got " + value.getClass());
} Type guard
boolean isBytesConvertible(Object v) {
return v instanceof byte[] || v instanceof ByteBuffer || v instanceof String;
} Try / catch
try {
return converter.convertBytes(bytesType, value);
} catch (UnsupportedOperationException e) {
LOG.warn("Bytes conversion failed for {}: {}", value.getClass(), e.getMessage());
return null;
} Prevention
- Convert wrapper byte containers (ByteString, ByteBuf) to byte[] before conversion.
- Use BYTES SqlType only for genuinely binary data.
- Agree on encoding when passing Strings that represent bytes (Base64 vs raw).
- Unit-test conversions with representative upstream types.
When it happens
Trigger: Calling convertBytes(typeDefine, value) — or convert(...) with a BYTES SqlType column — with an Integer, List of Bytes, POJO, InputStream, or other non-byte[]/ByteBuffer/String object.
Common situations: Upstream returns a boxed numeric or a protobuf ByteString instead of byte[]; passing a Base64 string where raw bytes were expected (works, since String is handled, but a wrapper object does not); deserialized collections of bytes.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Unsupported convert ${value.getClass()} to byte[]
- Unsupported convert %s to Map, typeDefine: %s
- Unsupported convert %s to Array, typeDefine: %s
- Unsupported convert ${value.getClass()} to Row, typeDefine:
- Unsupported convert ${value.getClass()} to LocalDateTime, ty
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/94523464fa64bb8d.
Report an issue: GitHub.