apache/seatunnel · error · IllegalArgumentException

Expected List type but got:

Error message

Expected List type but got: 

What it means

AerospikeSinkWriter.convertValue requires that fields configured as Aerospike LIST type implement Iterable; otherwise it throws IllegalArgumentException 'Expected List type but got: <class>'. The check guarantees the value can be stored as an Aerospike list without additional conversion.

Source

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

                    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();
        } catch (DateTimeParseException e) {
            try {
                return Instant.parse(datetime).toEpochMilli();
            } catch (DateTimeParseException ex) {
                throw new IllegalArgumentException("Unsupported datetime format: " + datetime);
            }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Fix the sink field's AEROSPIKE type to match the actual incoming type
  2. Use a transform (or source schema change) so the field is delivered as a List/Iterable
  3. Unwrap JSON strings into arrays upstream before the sink
  4. Read value.getClass() in the message to see the real type delivered

Example fix

// before
field { name = tags type = { data_type = LIST } } // upstream sends Object[]
// after: wrap upstream
Object[] raw = ...;
List<Object> tags = Arrays.asList(raw); // deliver Iterable
Defensive patterns

Strategy: type-guard

Validate before calling

Object v = row.getField(idx);
if (!(v instanceof Iterable)) throw new IllegalArgumentException("field 'tags' must be Iterable for LIST, got " + v.getClass());

Type guard

boolean isIterable(Object v) { return v instanceof Iterable; }

Try / catch

try { writer.write(row); } catch (AerospikeConnectorException e) { if (e.getCause() instanceof IllegalArgumentException && e.getCause().getMessage().startsWith("Expected List type")) { /* convert to List upstream */ } }

Prevention

When it happens

Trigger: A record field configured with AEROSPIKE data type LIST contains an object that is not an Iterable (e.g. a String, byte[], or Map-as-array edge cases) when write() invokes convertValue.

Common situations: Source emits arrays as Object[] or JSON strings instead of List; schema mismatch between upstream connector array representation and sink LIST expectation; type declared LIST while data is scalar.

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