{"record":{"id":"6ae0c4511cc4ef57","repo":"apache/seatunnel","slug":"expected-array-type-but-got","errorCode":null,"errorMessage":"Expected Array type but got: ","messagePattern":"Expected Array type but got: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-aerospike/src/main/java/org/apache/seatunnel/connectors/seatunnel/aerospike/sink/AerospikeSinkWriter.java","lineNumber":212,"sourceCode":"                    return timestamp.orElseGet(() -> Long.parseLong((String) value));\n                } else {\n                    return Long.parseLong(value.toString());\n                }\n            case DOUBLE:\n                if (value instanceof Number) {\n                    return ((Number) value).doubleValue();\n                }\n                return Double.parseDouble(value.toString());\n            case BOOLEAN:\n                if (value instanceof Boolean) {\n                    return value;\n                }\n                return Boolean.parseBoolean(value.toString());\n            case BYTEARRAY:\n                if (value.getClass().isArray()) {\n                    return value;\n                }\n                throw new IllegalArgumentException(\n                        \"Expected Array type but got: \" + value.getClass());\n            case LIST:\n                if (value instanceof Iterable) {\n                    return value;\n                }\n                throw new IllegalArgumentException(\n                        \"Expected List type but got: \" + value.getClass());\n            default:\n                throw new IllegalArgumentException(\"Unsupported AEROSPIKE data type: \" + dataType);\n        }\n    }\n\n    private long parseDateTimeString(String datetime) {\n        try {\n            return LocalDateTime.parse(datetime)\n                    .atZone(ZoneId.systemDefault())\n                    .toInstant()\n                    .toEpochMilli();","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-aerospike/src/main/java/org/apache/seatunnel/connectors/seatunnel/aerospike/sink/AerospikeSinkWriter.java#L194-L230","documentation":"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.","triggerScenarios":"A record field configured as Aerospike type BYTEARRAY carries a non-array Java object (e.g. String, ByteBuffer, List) when write() calls convertValue.","commonSituations":"Source table column declared as string/varbinary mismatch; upstream connector delivers String while sink config expects BYTEARRAY; schema drift between source and sink.","solutions":["Change the sink field's AEROSPIKE data type to match the actual incoming type (e.g. STRING)","Convert the upstream field to a byte[] in a transform before the sink","Fix the source schema so the field is emitted as byte[]","Check value.getClass() in the error message to identify the actual delivered type"],"exampleFix":"// before\nfield {\n  name = payload\n  type = { data_type = BYTEARRAY }\n}\n// after (upstream delivers String)\nfield {\n  name = payload\n  type = { data_type = STRING }\n}","handlingStrategy":"type-guard","validationCode":"Object v = row.getField(idx);\nif (!(v instanceof byte[])) throw new IllegalArgumentException(\"field 'payload' must be byte[] for BYTEARRAY, got \" + v.getClass());","typeGuard":"boolean isByteArray(Object v) { return v != null && v.getClass().isArray() && v.getClass().getComponentType() == byte.class; }","tryCatchPattern":"try { writer.write(row); } catch (AerospikeConnectorException e) { if (e.getCause() instanceof IllegalArgumentException && e.getCause().getMessage().startsWith(\"Expected Array type\")) { /* fix schema or transform field */ } }","preventionTips":["Match sink AEROSPIKE data types to the actual upstream field types","Add a transform to convert String/varbinary fields to byte[] before the sink","Validate a sample row's types against the configured types in a dry-run","Watch schema drift between source and sink definitions"],"tags":["aerospike","type-mismatch","schema","sink"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}