apache/seatunnel · error · IllegalArgumentException
Cannot convert to binary:
Error message
Cannot convert to binary:
What it means
Iceberg RowConverter throws this when a binary column value is not String (Base64), byte[], or ByteBuffer. convertBase64Binary supports exactly those three representations; anything else is rejected with the class name in the message.
Source
Thrown at seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/data/RowConverter.java:383
protected UUID convertUUID(Object value) {
if (value instanceof String) {
return UUID.fromString((String) value);
} else if (value instanceof UUID) {
return (UUID) value;
}
throw new IllegalArgumentException("Cannot convert to UUID: " + value.getClass().getName());
}
protected ByteBuffer convertBase64Binary(Object value) {
if (value instanceof String) {
return ByteBuffer.wrap(Base64.getDecoder().decode((String) value));
} else if (value instanceof byte[]) {
return ByteBuffer.wrap((byte[]) value);
} else if (value instanceof ByteBuffer) {
return (ByteBuffer) value;
}
throw new IllegalArgumentException(
"Cannot convert to binary: " + value.getClass().getName());
}
protected LocalDate convertDateValue(Object value) {
if (value instanceof Number) {
int days = ((Number) value).intValue();
return DateTimeUtil.dateFromDays(days);
} else if (value instanceof String) {
return LocalDate.parse((String) value);
} else if (value instanceof LocalDate) {
return (LocalDate) value;
} else if (value instanceof Date) {
int days = (int) (((Date) value).getTime() / 1000 / 60 / 60 / 24);
return DateTimeUtil.dateFromDays(days);
}
throw new RuntimeException("Cannot convert date: " + value);
}
View on GitHub (pinned to cf67b549a7)
Solutions
- Ensure the source emits byte[] or Base64-encoded String for binary fields.
- Add a transform to encode the value as Base64 string before the sink.
- Verify SeaTunnel schema maps the column to BytesType, not another type.
Example fix
// before writer.write(idx, someCustomBlobObject); // after writer.write(idx, Base64.getEncoder().encodeToString(blobBytes)); // String accepted
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(v instanceof String) && !(v instanceof byte[]) && !(v instanceof ByteBuffer)) throw new IllegalArgumentException("binary column must be String/byte[]/ByteBuffer, got " + (v == null ? "null" : v.getClass().getName())); Type guard
boolean isBinaryConvertible(Object v) { return v instanceof String || v instanceof byte[] || v instanceof ByteBuffer; } Try / catch
try { sink.write(row); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Cannot convert to binary")) { /* encode to Base64 or DLQ */ } else throw e; } Prevention
- Map source binary columns to SeaTunnel BytesType
- Base64-encode binary values when passing through JSON/text pipelines
- Avoid wrapping bytes in custom types before the sink
When it happens
Trigger: convertBase64Binary receives e.g. an Integer, BigDecimal, or arbitrary object while converting a field to an Iceberg BINARY column.
Common situations: Binary data serialized as JSON arrays/ints by a non-conforming source; nested structures mistakenly mapped to BINARY; file sources emitting image bytes wrapped in custom types.
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
- Cannot convert to BigDecimal:
- Cannot convert to boolean:
- Cannot convert to UUID:
- Cannot convert date:
- Cannot convert time:
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/2eb7b291c8637ef1.
Report an issue: GitHub.