{"record":{"id":"3d88f74f87f486e3","repo":"apache/cassandra","slug":"expected-a-list-but-got-a-s-s-3d88f7","errorCode":null,"errorMessage":"Expected a list, but got a %s: %s","messagePattern":"Expected a list, but got a (.+?): (.+?)","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/VectorType.java","lineNumber":319,"sourceCode":"        List<V> split = unpack(value, accessor);\n        for (int i = 0; i < dimension; i++)\n        {\n            if (i > 0)\n                sb.append(\", \");\n            sb.append(elementType.toJSONString(split.get(i), accessor, protocolVersion));\n        }\n        sb.append(']');\n        return sb.toString();\n    }\n\n    @Override\n    public Term fromJSONObject(Object parsed) throws MarshalException\n    {\n        if (parsed instanceof String)\n            parsed = JsonUtils.decodeJson((String) parsed);\n\n        if (!(parsed instanceof List))\n            throw new MarshalException(String.format(\n            \"Expected a list, but got a %s: %s\", parsed.getClass().getSimpleName(), parsed));\n\n        List<?> list = (List<?>) parsed;\n        if (list.size() != dimension)\n            throw new MarshalException(String.format(\"List had incorrect size: expected %d but given %d; %s\", dimension, list.size(), list));\n        List<Term> terms = new ArrayList<>(list.size());\n        for (Object element : list)\n        {\n            if (element == null)\n                throw new MarshalException(\"Invalid null element in list\");\n            terms.add(elementType.fromJSONObject(element));\n        }\n\n        return new MultiElements.DelayedValue(this, terms);\n    }\n\n    @Override\n    public boolean equals(Object o)","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/VectorType.java#L301-L337","documentation":"VectorType.fromJSONObject expects the parsed JSON value to be a JSON array (List). If the parsed object is any other JSON type (string, number, object, boolean), MarshalException is thrown naming the actual type received.","triggerScenarios":"Calling fromJSONObject with a JSON scalar or object, e.g. fromJSONObject(\"[1,2,3]\" as raw non-array) or JSON input like {\"v\": ...} instead of [...]; also when a string is passed it is first decoded, and the decoded value must still be a list.","commonSituations":"JSON-based insert paths (JSON statements, spark connector, REST layers) where the vector column received a scalar or object instead of an array; malformed user JSON payloads.","solutions":["Send the vector as a JSON array matching the dimension, e.g. [1.0, 2.0, 3.0]","Fix upstream JSON generation so the vector field is always an array","Validate the JSON structure before calling fromJSONObject"],"exampleFix":"// before\nString json = \"1.0, 2.0, 3.0\"; // scalar-ish\nterm = vectorType.fromJSONObject(json);\n// after\nString json = \"[1.0, 2.0, 3.0]\"; // proper array\nterm = vectorType.fromJSONObject(json);","handlingStrategy":"type-guard","validationCode":"if (!(parsed instanceof List)) throw new IllegalArgumentException(\"vector JSON must be an array, got \" + (parsed == null ? \"null\" : parsed.getClass().getSimpleName()));","typeGuard":"static boolean isJsonArray(Object o) { return o instanceof List; }","tryCatchPattern":"try { term = vt.fromJSONObject(parsed); } catch (MarshalException e) { /* log payload shape, return 400 */ }","preventionTips":["Ensure JSON generators emit arrays for vector columns","Validate payload JSON schema before insert"],"tags":["cassandra","json","vector-type","type-mismatch"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}