apache/seatunnel · error · IllegalArgumentException

Cannot convert to UUID:

Error message

Cannot convert to UUID: 

What it means

Iceberg RowConverter throws this when a UUID column value is neither String nor java.util.UUID. convertUUID only supports those two types; any other object (byte[16], Long, etc.) is rejected with the value's 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:372

            } else if (value instanceof Number || value instanceof Boolean) {
                return value.toString();
            } else if (value instanceof Map || value instanceof List) {
                return MAPPER.writeValueAsString(value);
            } else {
                return MAPPER.writeValueAsString(value);
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    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);

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Convert the value to String (e.g. UUID.toString() or hex-decode byte[]) before the sink.
  2. Add a transform to cast the column to STRING so convertUUID parses it via UUID.fromString.
  3. Fix the source connector type mapping to emit SeaTunnel StringType for UUID columns.

Example fix

// before
writer.write(idx, uuidBytes); // byte[16]
// after
ByteBuffer bb = ByteBuffer.wrap(uuidBytes);
writer.write(idx, new UUID(bb.getLong(), bb.getLong())); // java.util.UUID accepted
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(v instanceof UUID) && !(v instanceof String)) throw new IllegalArgumentException("uuid column must be UUID/String, got " + (v == null ? "null" : v.getClass().getName()));

Type guard

boolean isUuidConvertible(Object v) { return v instanceof UUID || v instanceof String; }

Try / catch

try { sink.write(row); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Cannot convert to UUID")) { /* convert byte[16] to UUID or DLQ */ } else throw e; }

Prevention

When it happens

Trigger: convertUUID receives a byte[] or other type while writing to an Iceberg UUID column, e.g. when a source connector represents UUIDs as fixed 16-byte binary.

Common situations: Postgres/MySQL UUID columns decoded as byte[] by a JDBC source; CDC records carrying UUID as binary; schema evolution changed the column type.

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


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/82285472b3063389. Report an issue: GitHub.