{"record":{"id":"d94aaa69a01ba963","repo":"apache/cassandra","slug":"cannot-parse-tuple-value-from-s-at-character-d94aaa","errorCode":null,"errorMessage":"Cannot parse tuple value from \"%s\", at character %d expecting ',' but got '%c'","messagePattern":"Cannot parse tuple 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":2988,"sourceCode":"                }\n                catch (IllegalArgumentException e)\n                {\n                    throw new InvalidTypeException(\n                    String.format(\n                    \"Cannot parse tuple value from \\\"%s\\\", invalid CQL value at character %d\",\n                    value, idx),\n                    e);\n                }\n\n                String input = value.substring(idx, n);\n                v = parseAndSetField(input, v, i);\n                idx = n;\n                i += 1;\n\n                idx = ParseUtils.skipSpaces(value, idx);\n                if (value.charAt(idx) == ')') return v;\n                if (value.charAt(idx) != ',')\n                    throw new InvalidTypeException(\n                    String.format(\n                    \"Cannot parse tuple value from \\\"%s\\\", at character %d expecting ',' but got '%c'\",\n                    value, idx, value.charAt(idx)));\n                ++idx; // skip ','\n\n                idx = ParseUtils.skipSpaces(value, idx);\n            }\n            throw new InvalidTypeException(\n            String.format(\"Malformed tuple value \\\"%s\\\", missing closing ')'\", value));\n        }\n\n        /**\n         * Return a new instance of {@code T}.\n         *\n         * @return A new instance of {@code T}.\n         */\n        protected abstract T newInstance();\n","sourceCodeStart":2970,"sourceCodeEnd":3006,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java#L2970-L3006","documentation":"While parsing a tuple literal, after reading a field the codec expects either ')' (end) or ',' (next field). If the character at the current position is neither, this InvalidTypeException is thrown naming the position and the actual character. It indicates malformed CQL tuple literal syntax between fields.","triggerScenarios":"Parsing \"(1 'abc')\" (missing comma), \"(1: 'abc')\" (wrong separator); extra spaces are fine but a semicolon or space separator instead of a comma triggers it.","commonSituations":"Hand-written literals in scripts or migrations with a missing comma between fields; templated CQL string building that dropped the comma; converting from JSON arrays [1,2] to tuple syntax incorrectly.","solutions":["Add the missing ',' between tuple fields: \"(1, 'abc')\".","Use a string template/join over the fields so commas are generated programmatically.","Parse fields yourself and construct the TupleValue via TupleType.newValue instead of literal parsing.","Check the reported character index; the offending character shows what replaced the expected comma."],"exampleFix":"// before\nTupleValue v = tupleType.parse(\"(1 'abc')\");\n// after\nTupleValue v = tupleType.parse(\"(1, 'abc')\");","handlingStrategy":"validation","validationCode":"if (!literal.matches(\"\\\\s*\\\\(\\\\s*.+(\\\\s*,\\\\s*.+)*\\\\s*\\\\)\\\\s*\")) throw new IllegalArgumentException(\"fields must be comma-separated inside parens\");","typeGuard":null,"tryCatchPattern":"try { return tupleType.parse(lit); } catch (InvalidTypeException e) { throw new IllegalArgumentException(\"malformed tuple separator: \" + lit, e); }","preventionTips":["Generate literals with String.join(\", \", fields) rather than concatenation","Lint CQL literals in migration scripts","Avoid hand-editing tuple literals; regenerate from typed values"],"tags":["parsing","tuple","cql-literal","syntax"],"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-17T15:17:12.973Z"}