{"record":{"id":"6c77ced71ef17601","repo":"apache/cassandra","slug":"cannot-parse-collection-value-from-s-at-charac-6c77ce","errorCode":null,"errorMessage":"Cannot parse collection value from \"%s\", at character %d expecting ',' but got '%c'","messagePattern":"Cannot parse collection value from \"(.+?)\", at character (.+?) expecting ',' but got '%c'","errorType":"exception","errorClass":"InvalidTypeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java","lineNumber":2220,"sourceCode":"                {\n                    n = ParseUtils.skipCQLValue(value, idx);\n                }\n                catch (IllegalArgumentException e)\n                {\n                    throw new InvalidTypeException(\n                    String.format(\n                    \"Cannot parse collection value from \\\"%s\\\", invalid CQL value at character %d\",\n                    value, idx),\n                    e);\n                }\n\n                l.add(eltCodec.parse(value.substring(idx, n)));\n                idx = n;\n\n                idx = ParseUtils.skipSpaces(value, idx);\n                if (value.charAt(idx) == getClosingChar()) return l;\n                if (value.charAt(idx++) != ',')\n                    throw new InvalidTypeException(\n                    String.format(\n                    \"Cannot parse collection value from \\\"%s\\\", at character %d expecting ',' but got '%c'\",\n                    value, idx, value.charAt(idx)));\n\n                idx = ParseUtils.skipSpaces(value, idx);\n            }\n            throw new InvalidTypeException(\n            String.format(\n            \"Malformed collection value \\\"%s\\\", missing closing '%s'\", value, getClosingChar()));\n        }\n\n        @Override\n        public boolean accepts(Object value)\n        {\n            if (getJavaType().getRawType().isAssignableFrom(value.getClass()))\n            {\n                // runtime type ok, now check element type\n                Collection<?> coll = (Collection<?>) value;","sourceCodeStart":2202,"sourceCodeEnd":2238,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java#L2202-L2238","documentation":"Thrown by collection codecs' parse() when, after consuming an element, the next non-space character is neither the closing character nor a comma, so the literal is structurally malformed. The message reports the character position and the offending character found.","triggerScenarios":"Calling parse() with missing or wrong separators, e.g. \"[1 2]\", \"[1;2]\", or \"{'a':'b' 'c':'d'}\" for a map; also happens with unescaped characters inside unquoted elements that swallow the comma position.","commonSituations":"Hand-built literals from string concatenation with wrong delimiters; values copied from other formats (JSON uses \"a\":1 vs CQL map a:1, semicolon-separated lists); truncated literals from logs where a quote was stripped.","solutions":["Use commas between elements: [1,2,3], {a:1,b:2}; ensure no stray spaces-as-separators or semicolons","Convert from JSON/other syntax to CQL literal syntax (map uses ':' key-value separator, not ':')","Quote string elements so special characters don't break delimiter scanning, and build literals via codec format() on a real Java collection instead of concatenation","Sanitize/validate the input string with a regex for the expected shape before calling parse()"],"exampleFix":"// before\nList<Integer> l = intListCodec.parse(\"[1 2 3]\"); // InvalidTypeException at char 3\n// after\nList<Integer> l = intListCodec.parse(\"[1,2,3]\");","handlingStrategy":"validation","validationCode":"// before parse\nString t = input == null ? \"\" : input.trim();\nif (!t.matches(\"\\\\[.*\\\\]|\\\\{.*\\\\}\"))\n    throw new IllegalArgumentException(\"Not a bracketed CQL collection literal: \" + input);\n// sanity: no whitespace/semicolon used as separator between elements\nif (t.contains(\";\")) throw new IllegalArgumentException(\"Use ',' as element separator\");","typeGuard":null,"tryCatchPattern":"try {\n    return codec.parse(literal);\n} catch (InvalidTypeException e) {\n    LOG.warn(\"Malformed collection literal (bad separator): {}\", e.getMessage());\n    return null;\n}","preventionTips":["Use commas between elements and ':' between map key and value","Generate literals via codec.format(Collection) rather than hand-concatenation","Quote all string elements so internal characters cannot corrupt delimiter scanning"],"tags":["cassandra","java-driver","parsing","cql-literal"],"backgroundTag":"invalid-argument-format","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"}