{"record":{"id":"80447c66f0e578e6","repo":"apache/cassandra","slug":"cannot-parse-tuple-value-from-s-at-character","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":2954,"sourceCode":"            for (int i = 0; i < length; i++)\n            {\n                if (i > 0) sb.append(',');\n                sb.append(formatField(value, i));\n            }\n            sb.append(')');\n            return sb.toString();\n        }\n\n        @Override\n        public T parse(String value)\n        {\n            if (value == null || value.isEmpty() || value.equalsIgnoreCase(\"NULL\")) return null;\n\n            T v = newInstance();\n\n            int idx = ParseUtils.skipSpaces(value, 0);\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\n            idx = ParseUtils.skipSpaces(value, idx);\n\n            if (value.charAt(idx) == ')') return v;\n\n            int i = 0;\n            while (idx < value.length())\n            {\n                int n;\n                try\n                {\n                    n = ParseUtils.skipCQLValue(value, idx);\n                }\n                catch (IllegalArgumentException e)\n                {","sourceCodeStart":2936,"sourceCodeEnd":2972,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java#L2936-L2972","documentation":"The tuple codec's parse method expects CQL literal syntax, which must begin with '('. If the first non-space character of the input string is anything else, this InvalidTypeException is thrown with the offending character and its position. It is a string-literal parsing error, not a network or serialization issue.","triggerScenarios":"Calling TupleCodec.parse with input like \"1, 'abc'\" or \"[1,'abc']\" instead of \"(1, 'abc')\"; binding a user-entered tuple literal that lacks the opening parenthesis.","commonSituations":"Users typing tuple values in cqlsh or a form without parentheses; JSON-ish input fed to parse; copying values from logs that stripped the parens.","solutions":["Wrap the value in parentheses: parse(\"(1, 'abc')\") instead of parse(\"1, 'abc'\").","Strip surrounding whitespace and validate the first non-space char is '(' before calling parse.","If the data is already structured, build a TupleValue via TupleType.newValue(...) instead of parsing strings.","Check for locale/formatting transformations that removed or replaced parentheses."],"exampleFix":"// before\nTupleValue v = tupleType.parse(\"1, 'abc'\");\n// after\nTupleValue v = tupleType.parse(\"(1, 'abc')\");","handlingStrategy":"validation","validationCode":"String s = input.trim(); if (!s.startsWith(\"(\")) throw new IllegalArgumentException(\"tuple literal must start with '(': \" + s);","typeGuard":null,"tryCatchPattern":"try { return tupleType.parse(literal); } catch (InvalidTypeException e) { throw new IllegalArgumentException(\"malformed tuple literal: \" + literal, e); }","preventionTips":["Validate CQL literals with a regex like \\s*\\(.*\\)\\s* before parsing","Prefer typed construction (TupleType.newValue) over string parsing","Trim input and normalize before parse"],"tags":["parsing","tuple","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-17T15:17:12.973Z"}