apache/seatunnel · error · UnsupportedOperationException

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

Error message

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

What it means

Thrown by BasicDataConverter.convertInt(Object value) when the value is neither LocalDate, LocalDateTime, nor a Number/String handled by default branches. The message names the actual class received so the developer can see exactly which type reached the INT conversion point.

Source

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

        if (value instanceof String) {
            return convertInt((String) value);
        }
        if (value instanceof Time) {
            return convertInt((Time) value);
        }
        if (value instanceof LocalTime) {
            return convertInt((LocalTime) value);
        }
        if (value instanceof Date) {
            return convertInt((Date) value);
        }
        if (value instanceof LocalDate) {
            return convertInt((LocalDate) value);
        }
        if (value instanceof LocalDateTime) {
            return convertInt((LocalDateTime) value);
        }
        throw new UnsupportedOperationException(
                "Unsupported convert " + value.getClass() + " to Integer");
    }

    default int convertInt(Number value) {
        return value.intValue();
    }

    default int convertInt(String value) {
        return Integer.parseInt(value);
    }

    default int convertInt(Time value) {
        return value.toLocalTime().toSecondOfDay();
    }

    default int convertInt(LocalTime value) {
        return value.toSecondOfDay();
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Pre-convert the value to Number/String/LocalDate before calling convertInt
  2. Align the source extraction so the field arrives as the declared catalog type
  3. Override convertInt(Object) in a custom converter to add support for the offending class

Example fix

// before
int i = converter.convertInt(row.getField(0)); // Boolean throws
// after
Object v = row.getField(0);
int i = (v instanceof Boolean) ? ((Boolean) v ? 1 : 0) : converter.convertInt(v);
Defensive patterns

Strategy: type-guard

Validate before calling

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

Type guard

static boolean isIntConvertible(Object v) {
    return v instanceof Number || v instanceof String || v instanceof LocalDate || v instanceof LocalDateTime;
}

Try / catch

try {
    i = converter.convertInt(value);
} catch (UnsupportedOperationException e) {
    LOG.warn("Cannot convert {} to int", value.getClass());
    i = 0;
}

Prevention

When it happens

Trigger: Calling the convertInt(Object) overload with String, Boolean, byte[], java.util.Date or arbitrary POJOs when an int is expected.

Common situations: Custom transform code calling the convenience overload directly with unconverted objects; schema drift after a table migration; connectors deserializing fields into generic Object rows.

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/15e522fe56e04b15. Report an issue: GitHub.