{"record":{"id":"a1dd7ac67957e9b1","repo":"apache/cassandra","slug":"invalid-null-value-for-slice-selection-on","errorCode":null,"errorMessage":"Invalid null value for slice selection on ","messagePattern":"Invalid null value for slice selection on ","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/selection/ElementsSelector.java","lineNumber":217,"sourceCode":"     * {@code Constants.UNSET_VALUE} if the slice doesn't have an end.\n     * @return the created factory.\n     */\n    public static Factory newSliceFactory(String name, Selector.Factory factory, CollectionType<?> type, final Term from, final Term to)\n    {\n        return new AbstractFactory(name, factory, type)\n        {\n            protected AbstractType<?> getReturnType()\n            {\n                return type;\n            }\n\n            public Selector newInstance(QueryOptions options) throws InvalidRequestException\n            {\n                ByteBuffer fromValue = from.bindAndGet(options);\n                ByteBuffer toValue = to.bindAndGet(options);\n                // Note that we use UNSET values to represent no bound, so null is truly invalid\n                if (fromValue == null || toValue == null)\n                    throw new InvalidRequestException(\"Invalid null value for slice selection on \" + factory.getColumnName());\n                return new SliceSelector(factory.newInstance(options), from.bindAndGet(options), to.bindAndGet(options));\n            }\n\n            public boolean areAllFetchedColumnsKnown()\n            {\n                // If we known all the fetched columns, it means that we don't have to wait execution to create\n                // the ColumnFilter (through addFetchedColumns below).\n                // That's the case if either there is no particular subselection\n                // to add, or if there is one but the selected bound are terminal. In other words,\n                // we known all the fetched columns if all the feched columns of the factory are known and either:\n                //  1) the type is frozen (in which case there isn't subselection to do).\n                //  2) the factory (the left-hand-side) isn't a simple column selection (here again, no\n                //     subselection we can do).\n                //  3) the bound of the selected slice are terminal.\n                return factory.areAllFetchedColumnsKnown()\n                        && (!type.isMultiCell() || !factory.isSimpleSelectorFactory() || (from.isTerminal() && to.isTerminal()));\n            }\n","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/selection/ElementsSelector.java#L199-L235","documentation":"Slice selection (e.g. SELECT s[?..?]) treats UNSET values as 'no bound', so a NULL bound endpoint is genuinely invalid. When either the from or to term binds to null (an explicit null parameter rather than unset), newInstance throws this error before building the SliceSelector.","triggerScenarios":"SELECT setOrMap[?..?] where at least one of the bound endpoint variables is explicitly set to null in the query parameters.","commonSituations":"Application code passes Java null for a slice bound intending 'open-ended'; in Cassandra open-ended slices use UNSET (omit) or literal bounds, not null.","solutions":["Pass UNSET / omit the variable instead of null for an open-ended bound","Use literal bounds in the CQL text (e.g. col[..5]) when the bound is static","Validate bound parameters for null before executing the statement"],"exampleFix":"// before\nbs.setBytes(0, null); // intended as open lower bound\n// after\nbs.setToUnset(0); // or: SELECT col[..5] literally","handlingStrategy":"validation","validationCode":"if (fromBound == null || toBound == null)\n    throw new IllegalArgumentException(\"slice bounds must not be null; use UNSET for open bounds\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Represent open slice bounds with UNSET or literal syntax, never null","Null-check bound parameters before execute","Document null-vs-unset semantics in data-access helpers"],"tags":["cql","bind-marker","slice-selection"],"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"}