{"record":{"id":"2f7a66fcb45f7a22","repo":"apache/cassandra","slug":"invalid-unset-value-for-s-in-s","errorCode":null,"errorMessage":"Invalid unset value for %s in %s","messagePattern":"Invalid unset value for (.+?) in (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/restrictions/SimpleRestriction.java","lineNumber":368,"sourceCode":"            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);\n                if (operator.kind() != Operator.Kind.BINARY)\n                {\n                    if (operator == Operator.IN && !column.type.isCounter())","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/restrictions/SimpleRestriction.java#L350-L386","documentation":"In a multicolumn restriction, one of the per-column element values is the UNSET sentinel. validateElements checks each ByteBuffer element against ByteBufferUtil.UNSET_BYTE_BUFFER and throws, identifying the column and columns expression.","triggerScenarios":"Executing a multi-column restriction like 'WHERE (a, b) > (?, ?)' where one tuple element was set to UNSET.","commonSituations":"Using unset-skip semantics on individual tuple components, which multicolumn restrictions do not support.","solutions":["Bind concrete values for all tuple components","Rebuild the query with only the fully-bound tuple restriction","Replace UNSET components with actual values or drop the whole predicate"],"exampleFix":"// before\nsession.execute(ps.bind(1, unsetValue));\n// after\nsession.execute(ps.bind(1, 2));","handlingStrategy":"validation","validationCode":"for (ByteBuffer b : elements) if (b == null || b == UNSET_SENTINEL) throw new IllegalArgumentException(\"unset tuple element\");","typeGuard":"boolean tupleFullySet(java.nio.ByteBuffer[] t) { return java.util.Arrays.stream(t).allMatch(b -> b != null && b != UNSET_SENTINEL); }","tryCatchPattern":"catch (InvalidRequestException e) { if (e.getMessage().contains(\"Invalid unset value\")) rebuildQuery(); }","preventionTips":["Do not mix UNSET sentinels into multicolumn restrictions","Assemble tuples only from present values","Fall back to single-column restrictions when tuple data is incomplete"],"tags":["cql","multicolumn-restriction","unset-value","query-validation"],"backgroundTag":"invalid-argument-value","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"}