apache/seatunnel · error · UnsupportedOperationException

Unsupported convert to Byte

Error message

Unsupported convert ${value.getClass()} to Byte

What it means

Thrown by BasicDataConverter.convertByte(Object value) when the value is neither a String nor a Boolean (numeric handling lives in the convertByte(Number) overload). The message reports the class of the value that could not be converted to a byte.

Solutions

  1. Pre-convert the value to String/Boolean/Number before calling convertByte
  2. Fix the catalog schema so the declared type matches the data actually produced by the source
  3. Override convertByte(Object) in a custom converter to add the missing class branch

Example fix

// before
byte b = converter.convertByte(row.getField(0)); // LocalDate throws
// after
Object v = row.getField(0);
byte b = (v instanceof LocalDate) ? (byte) ((LocalDate) v).toEpochDay() : converter.convertByte(v);
Defensive patterns

Strategy: type-guard

Validate before calling

Object v = row.getField(0);
if (!(v instanceof Number) && !(v instanceof String) && !(v instanceof Boolean)) {
    throw new IllegalArgumentException("Value " + v.getClass() + " cannot be converted to byte");
}

Type guard

static boolean isByteConvertible(Object v) {
    return v instanceof Number || v instanceof String || v instanceof Boolean;
}

Try / catch

try {
    b = converter.convertByte(value);
} catch (UnsupportedOperationException e) {
    LOG.warn("Cannot convert {} to byte", value.getClass());
    b = 0;
}

Prevention

When it happens

Trigger: Calling the convertByte(Object) overload with byte[], LocalDate, Number (if not routed to the Number overload), or arbitrary objects while expecting a TINYINT value.

Common situations: Generic Object-row transforms feeding scalar converters; schema drift after table migrations; direct use of the convenience overload with unconverted values in custom connector code.

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/1b69715d4f62baa9. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java:1267

    default byte convertByte(T typeDefine, boolean value) {
        return convertByte(value);
    }

    default byte convertByte(Object value) throws UnsupportedOperationException {
        if (value instanceof Byte) {
            return (byte) value;
        }
        if (value instanceof Number) {
            return convertByte((Number) value);
        }
        if (value instanceof String) {
            return convertByte((String) value);
        }
        if (value instanceof Boolean) {
            return convertByte(((boolean) value));
        }
        throw new UnsupportedOperationException(
                "Unsupported convert " + value.getClass() + " to Byte");
    }

    default byte convertByte(Number value) {
        return value.byteValue();
    }

    default byte convertByte(String value) {
        return Byte.parseByte(value);
    }

    default byte convertByte(boolean value) {
        return value ? (byte) 1 : (byte) 0;
    }

    default boolean convertBoolean(T typeDefine, Object value)
            throws UnsupportedOperationException {
        if (value instanceof Boolean) {

View on GitHub (pinned to cf67b549a7)