{"record":{"id":"343e9c910e8bf1c9","repo":"apache/cassandra","slug":"invalid-null-value-for-s-in-s","errorCode":null,"errorMessage":"Invalid null value for %s in %s","messagePattern":"Invalid null value for (.+?) in (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/restrictions/SimpleRestriction.java","lineNumber":365,"sourceCode":"    private void validate(ByteBuffer buffer)\n    {\n        if (buffer == null)\n            throw invalidRequest(\"Invalid null value for %s\", columnsExpression);\n        if (buffer == ByteBufferUtil.UNSET_BYTE_BUFFER)\n            throw invalidRequest(\"Invalid unset value for %s\", columnsExpression);\n    }\n\n    private void validateElements(List<ByteBuffer> elements)\n    {\n        validate(elements);\n\n        List<ColumnMetadata> columns = columns();\n        for (int i = 0, m = columns.size(); i < m; i++)\n        {\n            ColumnMetadata column = columns.get(i);\n            ByteBuffer element = elements.get(i);\n            if (element == null)\n                throw invalidRequest(\"Invalid null value for %s in %s\",\n                                     column.name.toCQLString(), columnsExpression);\n            if (element == ByteBufferUtil.UNSET_BYTE_BUFFER)\n                throw invalidRequest(\"Invalid unset value for %s in %s\",\n                                     column.name.toCQLString(), columnsExpression);\n        }\n    }\n\n    @Override\n    public void addToRowFilter(RowFilter filter, IndexRegistry indexRegistry, FunctionContext context, IndexHints indexHints)\n    {\n        if (isOnToken())\n            throw new UnsupportedOperationException();\n\n        ColumnMetadata column = firstColumn();\n        switch (columnsExpression.kind())\n        {\n            case SINGLE_COLUMN:\n                List<ByteBuffer> buffers = bindAndGet(context);","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/restrictions/SimpleRestriction.java#L347-L383","documentation":"In a multicolumn restriction, one of the per-column element values bound for the restriction is null. validateElements iterates each column of the tuple/multi-column expression and throws, naming both the offending column and the columns expression.","triggerScenarios":"Executing 'WHERE (a, b) = (?, ?)' with one of the tuple's bound values null.","commonSituations":"Partial tuple bindings from application code where some tuple components are missing; mapping a nullable struct to a CQL tuple restriction.","solutions":["Ensure every component of the multi-column tuple is bound to a non-null value","Restrict only the columns whose values are known and drop the tuple predicate otherwise","Validate tuple elements client-side before binding"],"exampleFix":"// before\nsession.execute(ps.bind(1, null)); // (a, b) = (?, ?)\n// after\nsession.execute(ps.bind(1, \"x\"));","handlingStrategy":"validation","validationCode":"Object[] tuple = ...; for (Object o : tuple) if (o == null) throw new IllegalArgumentException(\"tuple element null\");","typeGuard":"boolean tupleComplete(Object[] t) { return java.util.Arrays.stream(t).allMatch(java.util.Objects::nonNull); }","tryCatchPattern":"catch (InvalidRequestException e) { if (e.getMessage().contains(\"Invalid null value\")) logMissingTupleComponents(); }","preventionTips":["Only build tuple restrictions from fully populated tuples","Validate tuple arity and completeness before binding","Map nullable domain objects to partial predicates, never partial tuples"],"tags":["cql","multicolumn-restriction","null-value","query-validation"],"backgroundTag":"null-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"}