{"record":{"id":"476ce5baee8a071a","repo":"apache/cassandra","slug":"invalid-null-element-in-list-476ce5","errorCode":null,"errorMessage":"Invalid null element in list","messagePattern":"Invalid null element in list","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/VectorType.java","lineNumber":329,"sourceCode":"\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)\n    {\n        if (this == o) return true;\n        if (o == null || getClass() != o.getClass()) return false;\n        VectorType<?> that = (VectorType<?>) o;\n        return dimension == that.dimension && Objects.equals(elementType, that.elementType);\n    }\n\n    @Override\n    public int hashCode()\n    {","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/VectorType.java#L311-L347","documentation":"While converting each element of the JSON array into a Term, fromJSONObject rejects JSON null elements with MarshalException, since vectors cannot contain null elements (same rule as the binary validation path).","triggerScenarios":"JSON insert containing nulls inside the vector array, e.g. [1.0, null, 3.0] for a vector column.","commonSituations":"Data pipelines with missing embeddings emitting null placeholders; user-supplied JSON with nulls; ETL joins producing nulls for missing values.","solutions":["Remove nulls from the JSON array or substitute default values","Reject/repair such records upstream before insert","Coerce nulls to a sentinel like 0.0 if semantically acceptable"],"exampleFix":"// before\njson = \"[0.1, null, 0.3]\";\n// after\njson = \"[0.1, 0.0, 0.3]\";","handlingStrategy":"validation","validationCode":"boolean containsNull = list.stream().anyMatch(Objects::isNull);\nif (containsNull) throw new IllegalArgumentException(\"null element in vector JSON\");","typeGuard":"static <T> boolean noNulls(List<T> l) { return l.stream().noneMatch(Objects::isNull); }","tryCatchPattern":"try { term = vt.fromJSONObject(list); } catch (MarshalException e) { /* null element: reject record */ }","preventionTips":["Replace nulls with defaults upstream","Reject records with null embeddings at ingest"],"tags":["cassandra","json","null","vector-type"],"backgroundTag":"null-argument","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"}