{"record":{"id":"d61d7e6ace27a8d0","repo":"apache/cassandra","slug":"tuple-is-missing-items-expected-s-s","errorCode":null,"errorMessage":"Tuple is missing items (expected %s): %s","messagePattern":"Tuple is missing items \\(expected (.+?)\\): (.+?)","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/TupleType.java","lineNumber":503,"sourceCode":"        return pack(fields);\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 representation of a tuple, but got a %s: %s\", parsed.getClass().getSimpleName(), parsed));\n\n        List<?> list = (List<?>) parsed;\n\n        if (list.size() > types.size())\n            throw new MarshalException(String.format(\"Tuple contains extra items (expected %s): %s\", types.size(), parsed));\n        else if (types.size() > list.size())\n            throw new MarshalException(String.format(\"Tuple is missing items (expected %s): %s\", types.size(), parsed));\n\n        List<Term> terms = new ArrayList<>(list.size());\n        Iterator<AbstractType<?>> typeIterator = types.iterator();\n        for (Object element : list)\n        {\n            if (element == null)\n            {\n                typeIterator.next();\n                terms.add(Constants.NULL_VALUE);\n            }\n            else\n            {\n                terms.add(typeIterator.next().fromJSONObject(element));\n            }\n        }\n\n        return new MultiElements.DelayedValue(this, terms);\n    }","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/TupleType.java#L485-L521","documentation":"In TupleType.fromJSONObject, if the JSON list has fewer elements than the tuple type declares, this MarshalException is thrown. Unlike variable-length bind semantics, a JSON tuple literal must supply an item for every declared field (use explicit nulls where allowed).","triggerScenarios":"INSERT JSON with a shorter array, e.g. tuple<int,int> given [1]; calling fromJSONObject with a partial list.","commonSituations":"Application serializers omitting trailing null fields; schema added a field to the tuple and old payloads no longer match; hand-written JSON in scripts/tests.","solutions":["Provide all declared fields in the array, using null for fields that should be null","Re-check the tuple arity in the current schema","Regenerate payloads from updated schema definitions after ALTER","Validate array length client-side before insert"],"exampleFix":"// before: tuple<int,int> missing second field\n{\"t\": [1]}\n// after\n{\"t\": [1, null]}","handlingStrategy":"validation","validationCode":"if (((List<?>) parsed).size() < types.size()) throw new IllegalArgumentException(\"JSON tuple is missing items; use explicit nulls\");","typeGuard":null,"tryCatchPattern":"try {\n    tupleType.fromJSONObject(parsed);\n} catch (MarshalException e) {\n    throw new IllegalArgumentException(\"incomplete tuple JSON: \" + e.getMessage());\n}","preventionTips":["Always emit an element for every declared tuple field, using null where allowed","Update payload generators when tuple fields are added","Validate JSON arrays in application code before sending"],"tags":["json","tuple","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}