{"record":{"id":"602352ea2910241e","repo":"apache/seatunnel","slug":"list-type-requires-list-value-got-value-getcla","errorCode":null,"errorMessage":"List type requires List value, got: ${value.getClass()}","messagePattern":"List type requires List value, got: (.+?)","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/utils/FragmentConverter.java","lineNumber":108,"sourceCode":"\n        if (arrowType instanceof ArrowType.List) {\n            writeListToVector((ListVector) vector, field, value, rowIndex, allocator);\n        } else if (arrowType instanceof ArrowType.Map) {\n            writeMapToVector((MapVector) vector, field, value, rowIndex, allocator);\n        } else {\n            TypeWriter writer = TypeWriterFactory.getWriter(arrowType);\n            writer.writeToVector(vector, arrowType, value, rowIndex, allocator);\n        }\n    }\n\n    private static void writeListToVector(\n            ListVector listVector,\n            Field field,\n            Object value,\n            int rowIndex,\n            BufferAllocator allocator) {\n        if (!(value instanceof java.util.List)) {\n            throw new IllegalArgumentException(\n                    \"List type requires List value, got: \" + value.getClass());\n        }\n\n        UnionListWriter writer = listVector.getWriter();\n        writer.setPosition(rowIndex);\n        writer.startList();\n\n        java.util.List<?> listValue = (java.util.List<?>) value;\n        List<Field> children = field.getChildren();\n        if (children.isEmpty()) {\n            throw new IllegalArgumentException(\"List field must have a child field\");\n        }\n        Field elementField = children.get(0);\n        ArrowType elementType = elementField.getType();\n\n        for (Object element : listValue) {\n            writeListElement(writer, elementType, element, allocator);\n        }","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/utils/FragmentConverter.java#L90-L126","documentation":"FragmentConverter.writeListToVector requires the Java value behind an Arrow LIST column to be a java.util.List. When the Lance sink's row value for a list-typed column is any other object (array primitive, string, map, etc.), the cast guard throws this IllegalArgumentException with the actual runtime class.","triggerScenarios":"SeaTunnel Row field for a column declared ARRAY carries a non-List object — e.g. a String containing JSON, a Scala/other collection type, or a single element not wrapped in a list — and setVectorValue dispatches it to writeListToVector.","commonSituations":"Custom transforms/sources that set the field to a raw JSON string for an array column; type drift after schema changes (column re-typed to array but data pipeline not updated); passing Java arrays (Object[]) instead of List.","solutions":["Wrap the value in a java.util.List (e.g. Arrays.asList(...) for Object[]) before writing the row.","If the value is a JSON string, parse it into a List first rather than passing the raw string.","Verify the SeaTunnel column type matches the actual value type produced by your source/transform.","Use Arrays.asList(java.util.Arrays.stream(arr).boxed().toArray()) conversion helpers if the producer only has primitive arrays."],"exampleFix":"// before\nrow.setField(2, \"{\\\"a\\\":1}\");  // string for array column\n\n// after\nrow.setField(2, java.util.Arrays.asList(\"a\", \"b\"));","handlingStrategy":"type-guard","validationCode":"// Java: ensure the value is a List before writing\nif (!(value instanceof java.util.List)) {\n    throw new IllegalArgumentException(\"Array column requires java.util.List value\");\n}","typeGuard":"boolean isListValue(Object v) {\n    return v instanceof java.util.List;\n}\n\nObject normalize(Object v) {\n    if (v instanceof Object[]) return java.util.Arrays.asList((Object[]) v);\n    return v;\n}","tryCatchPattern":"try {\n    fragmentConverter.writeListToVector(listVector, field, value, rowIndex, allocator);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"List type requires List value\")) {\n        throw new IllegalStateException(\"Producer must emit java.util.List for array column '\" + field.getName() + \"'\", e);\n    }\n    throw e;\n}","preventionTips":["Always wrap array column values in java.util.List (Arrays.asList, not Object[])","Parse JSON strings into Lists before setting row fields","Keep source/transform output types aligned with the declared SeaTunnel schema"],"tags":["lance","arrow","type-mismatch","list","validation"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}