{"record":{"id":"8b28c2b66ce52ce4","repo":"apache/cassandra","slug":"invalid-set-literal-for-s-of-type-s","errorCode":null,"errorMessage":"Invalid set literal for %s of type %s","messagePattern":"Invalid set literal for (.+?) of type (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/terms/Sets.java","lineNumber":189,"sourceCode":"\n                values.add(t);\n            }\n            MultiElements.DelayedValue value = new MultiElements.DelayedValue((MultiElementType<?>) receiver.type.unwrap(), values);\n            return allTerminal ? value.bind(FunctionContext.NONE) : value;\n        }\n\n        private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException\n        {\n            AbstractType<?> type = receiver.type.unwrap();\n\n            if (!(type instanceof SetType))\n            {\n                // We've parsed empty maps as a set literal to break the ambiguity so\n                // handle that case now\n                if ((type instanceof MapType) && elements.isEmpty())\n                    return;\n\n                throw new InvalidRequestException(String.format(\"Invalid set literal for %s of type %s\", receiver.name, receiver.type.asCQL3Type()));\n            }\n\n            ColumnSpecification valueSpec = Sets.valueSpecOf(receiver);\n            for (Term.Raw rt : elements)\n            {\n                if (!rt.testAssignment(keyspace, valueSpec).isAssignable())\n                    throw new InvalidRequestException(String.format(\"Invalid set literal for %s: value %s is not of type %s\", receiver.name, rt, valueSpec.type.asCQL3Type()));\n            }\n        }\n\n        public AssignmentTestable.TestResult testAssignment(String keyspace, ColumnSpecification receiver)\n        {\n            return testSetAssignment(receiver, elements);\n        }\n\n        @Override\n        public AbstractType<?> getExactTypeIfKnown(String keyspace)\n        {","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/terms/Sets.java#L171-L207","documentation":"Generic validation guard in Sets.prepare: the receiver column is neither a set nor (for the empty-literal ambiguity case) a map, so a set literal cannot be assigned to it. The message names the column and its actual CQL type; the input at fault is the mismatched target column of the set literal.","triggerScenarios":"Thrown at src/java/org/apache/cassandra/cql3/terms/Sets.java:189 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a set literal only against a set-typed column; use a map literal for map columns","Check the target column's type with DESCRIBE and correct the statement"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}