{"record":{"id":"3ee1cae1fe04c9e7","repo":"apache/cassandra","slug":"cannot-parse-tuple-value-from-s-invalid-cql-va","errorCode":null,"errorMessage":"Cannot parse tuple value from \"%s\", invalid CQL value at character %d","messagePattern":"Cannot parse tuple value from \"(.+?)\", invalid CQL value at character (.+?)","errorType":"exception","errorClass":"InvalidTypeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java","lineNumber":2973,"sourceCode":"                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                {\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)));","sourceCodeStart":2955,"sourceCodeEnd":2991,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java#L2955-L2991","documentation":"Inside the tuple codec's parse loop, each field value is scanned with ParseUtils.skipCQLValue. When the characters at the current position do not form a valid CQL value for the next field, skipCQLValue throws IllegalArgumentException, which the codec rethrows as this InvalidTypeException indicating the offending character index.","triggerScenarios":"Parsing \"(abc, 2)\" for a tuple whose first field is int (non-numeric literal), unquoted strings without quotes like (hello, 1), stray characters such as (1; 2), or a literal terminated early like (1, ).","commonSituations":"Typo in a literal during manual cqlsh inserts; user-supplied form data bound directly as CQL literal; values copied from another serialization format.","solutions":["Fix the literal so every field is a valid CQL value for its declared type (quote strings: ('abc', 2)).","Validate field values against the TupleType component types before parsing.","Construct the TupleValue programmatically with TupleType.newValue(...) to bypass string parsing entirely.","Inspect the reported character index in the message to locate the malformed field."],"exampleFix":"// before\nTupleValue v = tupleType.parse(\"(abc, 2)\"); // 'abc' not valid for int field\n// after\nTupleValue v = tupleType.parse(\"(1, 'abc')\"); // reorder or quote correctly per field types","handlingStrategy":"validation","validationCode":"for (int i = 0; i < values.length; i++) if (!tupleType.getComponentTypes().get(i).accepts(values[i])) throw new IllegalArgumentException(\"field \" + i + \" invalid\");","typeGuard":null,"tryCatchPattern":"try { return tupleType.parse(literal); } catch (InvalidTypeException e) { throw new IllegalArgumentException(\"bad CQL value: \" + e.getMessage(), e); }","preventionTips":["Quote string fields with single quotes in literals","Use typed newValue(...) construction instead of literals","Escape single quotes inside string literals by doubling them"],"tags":["parsing","cql-literal","tuple"],"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"}