{"record":{"id":"89c78ede8d98a80a","repo":"apache/cassandra","slug":"unexpected-receiver-type-s-only-list-and-vecto","errorCode":null,"errorMessage":"Unexpected receiver type '%s'; only list and vector are expected","messagePattern":"Unexpected receiver type '(.+?)'; only list and vector are expected","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/terms/ArrayLiteral.java","lineNumber":49,"sourceCode":" * so this class is meant to act as a proxy once the real type is known.\n */\npublic class ArrayLiteral extends Term.Raw\n{\n    private final List<Term.Raw> elements;\n\n    public ArrayLiteral(List<Term.Raw> elements)\n    {\n        this.elements = elements;\n    }\n\n    private Term.Raw forReceiver(ColumnSpecification receiver)\n    {\n        AbstractType<?> type = receiver.type.unwrap();\n        if (type instanceof VectorType)\n            return new Vectors.Literal(elements);\n        if (type instanceof ListType)\n            return new Lists.Literal(elements);\n        throw new InvalidRequestException(String.format(\"Unexpected receiver type '%s'; only list and vector are expected\", type.asCQL3Type()));\n    }\n\n    @Override\n    public Term prepare(String keyspace, ColumnSpecification receiver) throws InvalidRequestException\n    {\n        return forReceiver(receiver).prepare(keyspace, receiver);\n    }\n\n    @Override\n    public TestResult testAssignment(String keyspace, ColumnSpecification receiver)\n    {\n        return forReceiver(receiver).testAssignment(keyspace, receiver);\n    }\n\n    @Override\n    public AbstractType<?> getExactTypeIfKnown(String keyspace)\n    {\n        // without knowing the receiver, can't say if this is a ListType or a VectorType","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/terms/ArrayLiteral.java#L31-L67","documentation":"An ArrayLiteral ([...], e.g. a bind marker [?] or array literal) can only be bound to a column whose type is a list or a vector. forReceiver() inspects the receiver column's unwrapped type and throws InvalidRequestException for any other receiver type (set, map, tuple, scalar, etc.).","triggerScenarios":"Using `[?]`/`[...]` syntax against a column of unsupported type, e.g. `INSERT INTO t (s) VALUES ([?])` where s is a set or text; preparing array-literal terms in testAssignment against non-list/vector receivers.","commonSituations":"Mixing up [ ] (list) with { } (set/map) collection literals; generic query builders choosing array syntax for all collections; vectors vs lists confusion after version changes.","solutions":["Use the matching collection literal for the column type: {…} for sets/maps, (…) for tuples","Change the target column to a list or vector type if array semantics are required","Use a plain bind marker ? and pass the collection value in code"],"exampleFix":"// before\nINSERT INTO t (s) VALUES ([1, 2, 3]);  -- s is a set<int>\n// after\nINSERT INTO t (s) VALUES ({1, 2, 3});  -- set literal","handlingStrategy":"type-guard","validationCode":"function canUseArrayLiteral(colType) {\n  const t = colType.replace(/^frozen<|>$/g, '');\n  return t.startsWith('list<') || t.startsWith('vector<');\n}","typeGuard":"function isArrayAssignable(receiver) {\n  const t = receiver.type.unwrap();\n  return t instanceof VectorType || t instanceof ListType;\n}","tryCatchPattern":"try {\n  session.execute(query, params);\n} catch (e) {\n  if (/Unexpected receiver type/.test(e.message)) { /* switch collection literal/bind syntax to match column type */ }\n  else throw e;\n}","preventionTips":["Match literal syntax to column type: [ ] lists, { } sets/maps, ( ) tuples","Check column types from table metadata before choosing bind syntax","Prefer generic bind markers (?) and pass typed values from the driver"],"tags":["cql","collections","type-mismatch","bind-marker"],"backgroundTag":"type-mismatch","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}