{"record":{"id":"69637fcc2c6596ef","repo":"apache/cassandra","slug":"invalid-set-literal-for-s-value-s-is-not-of-typ","errorCode":null,"errorMessage":"Invalid set literal for %s: value %s is not of type %s","messagePattern":"Invalid set literal for (.+?): value (.+?) is not of type (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/terms/Sets.java","lineNumber":196,"sourceCode":"        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        {\n            return getExactSetTypeIfKnown(elements, p -> p.getExactTypeIfKnown(keyspace));\n        }\n\n        @Override\n        public AbstractType<?> getCompatibleTypeIfKnown(String keyspace)\n        {\n            return Sets.getPreferredCompatibleType(elements, p -> p.getCompatibleTypeIfKnown(keyspace));","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/terms/Sets.java#L178-L214","documentation":"Fired after the receiver is confirmed a set type: an individual element of the set literal is not assignable to the set's element type (TestResult.NOT_ASSIGNABLE). The message names the column, the offending element, and the expected element type; it is a per-element type validation in set-literal preparation.","triggerScenarios":"Thrown at src/java/org/apache/cassandra/cql3/terms/Sets.java:196 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Change the literal element that has the wrong type to match the set's declared element type","Alter the column or cast the value so element types are compatible"],"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"}