apache/seatunnel · error · IllegalArgumentException

Expected Array type but got:

Error message

Expected Array type but got: 

What it means

AerospikeSinkWriter.convertValue validates the runtime type of each field against the configured Aerospike data type; for the BYTEARRAY case the value's class must be an array, otherwise it throws IllegalArgumentException 'Expected Array type but got: <class>'. This enforces that the incoming SeaTunnel field actually holds a byte array before writing it as an Aerospike blob.

Source

Thrown at seatunnel-connectors-v2/connector-aerospike/src/main/java/org/apache/seatunnel/connectors/seatunnel/aerospike/sink/AerospikeSinkWriter.java:212

                    return timestamp.orElseGet(() -> Long.parseLong((String) value));
                } else {
                    return Long.parseLong(value.toString());
                }
            case DOUBLE:
                if (value instanceof Number) {
                    return ((Number) value).doubleValue();
                }
                return Double.parseDouble(value.toString());
            case BOOLEAN:
                if (value instanceof Boolean) {
                    return value;
                }
                return Boolean.parseBoolean(value.toString());
            case BYTEARRAY:
                if (value.getClass().isArray()) {
                    return value;
                }
                throw new IllegalArgumentException(
                        "Expected Array type but got: " + value.getClass());
            case LIST:
                if (value instanceof Iterable) {
                    return value;
                }
                throw new IllegalArgumentException(
                        "Expected List type but got: " + value.getClass());
            default:
                throw new IllegalArgumentException("Unsupported AEROSPIKE data type: " + dataType);
        }
    }

    private long parseDateTimeString(String datetime) {
        try {
            return LocalDateTime.parse(datetime)
                    .atZone(ZoneId.systemDefault())
                    .toInstant()
                    .toEpochMilli();

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Change the sink field's AEROSPIKE data type to match the actual incoming type (e.g. STRING)
  2. Convert the upstream field to a byte[] in a transform before the sink
  3. Fix the source schema so the field is emitted as byte[]
  4. Check value.getClass() in the error message to identify the actual delivered type

Example fix

// before
field {
  name = payload
  type = { data_type = BYTEARRAY }
}
// after (upstream delivers String)
field {
  name = payload
  type = { data_type = STRING }
}
Defensive patterns

Strategy: type-guard

Validate before calling

Object v = row.getField(idx);
if (!(v instanceof byte[])) throw new IllegalArgumentException("field 'payload' must be byte[] for BYTEARRAY, got " + v.getClass());

Type guard

boolean isByteArray(Object v) { return v != null && v.getClass().isArray() && v.getClass().getComponentType() == byte.class; }

Try / catch

try { writer.write(row); } catch (AerospikeConnectorException e) { if (e.getCause() instanceof IllegalArgumentException && e.getCause().getMessage().startsWith("Expected Array type")) { /* fix schema or transform field */ } }

Prevention

When it happens

Trigger: A record field configured as Aerospike type BYTEARRAY carries a non-array Java object (e.g. String, ByteBuffer, List) when write() calls convertValue.

Common situations: Source table column declared as string/varbinary mismatch; upstream connector delivers String while sink config expects BYTEARRAY; schema drift between source and sink.

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/6ae0c4511cc4ef57. Report an issue: GitHub.