{"record":{"id":"02b3ff8545e55c0f","repo":"apache/cassandra","slug":"syntax-error-parsing-s-for-msg-unexpected-chara","errorCode":null,"errorMessage":"Syntax error parsing '%s: for msg unexpected character '%s'","messagePattern":"Syntax error parsing '(.+?): for msg unexpected character '(.+?)'","errorType":"validation","errorClass":"SyntaxException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/TypeParser.java","lineNumber":190,"sourceCode":"        ++idx; // skipping '('\n        skipBlank();\n\n        String k = readNextIdentifier();\n        IPartitioner partitioner = FBUtilities.newPartitioner(k);\n        skipBlank();\n        if (str.charAt(idx) == ':')\n        {\n            ++idx;\n            skipBlank();\n            // must be PartitionerDefinedOrder\n            return partitioner.partitionOrdering(parse());\n        }\n        else if (str.charAt(idx) == ')')\n        {\n            idx = initIdx;\n            return partitioner.partitionOrdering(null);\n        }\n        throw new SyntaxException(\"Syntax error parsing '\" + str + \": for msg unexpected character '\" + str.charAt(idx) + \"'\");\n    }\n\n    public static String stringifyTKeyValueParameters(Map<String, String> map)\n    {\n        StringBuilder sb = new StringBuilder();\n        sb.append('(');\n        for (Map.Entry<String, String> e : map.entrySet())\n            sb.append(e.getKey()).append(\" = \").append(e.getValue()).append(\", \");\n        if (!map.isEmpty())\n            sb.setLength(sb.length() - 2);\n        return sb.append(')').toString();\n    }\n\n    public Map<String, String> getKeyValueParameters() throws SyntaxException\n    {\n        if (isEOS())\n            return Collections.emptyMap();\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/TypeParser.java#L172-L208","documentation":"TypeParser.getPartitionerDefinedOrder parses an empty-partition-order type expression of the form 'partitioner(...)'. If, after consuming the parenthesized content, the current character is not the expected ')' (or the input ends unexpectedly), it throws a SyntaxException describing the unexpected character. This indicates a malformed type string in schema/config input.","triggerScenarios":"Specifying a reverse/ordered comparator string with an unbalanced or misplaced parenthesis (e.g. 'partitioner(bytes' or 'partitioner)x'), typically from a table's comparator option or a CLI argument parsed via TypeParser.","commonSituations":"Hand-editing cassandra-cli/schema scripts with typos in type expressions; copying type strings across versions with changed syntax; automation generating unbalanced parentheses.","solutions":["Fix the type string so it reads exactly 'partitioner(...)' with balanced parentheses","Use a simpler supported type name if the partitioner-defined order isn't required","Check the exact string being parsed (schema definition, CLI arg) and quote it properly","Verify version-appropriate syntax for the type expression"],"exampleFix":"// before\nTypeParser.parse(\"partitioner(org.apache.cassandra.dht.Murmur3Partitioner\"); // missing ')'\n// after\nTypeParser.parse(\"partitioner(org.apache.cassandra.dht.Murmur3Partitioner)\");","handlingStrategy":"validation","validationCode":"String s = typeString.trim();\nif (s.startsWith(\"partitioner(\") && !s.endsWith(\")\"))\n    throw new IllegalArgumentException(\"malformed partitioner type expression: \" + s);","typeGuard":null,"tryCatchPattern":"try {\n    TypeParser.getPartitionerDefinedOrder(str);\n} catch (SyntaxException e) {\n    throw new IllegalArgumentException(\"bad type string: \" + e.getMessage());\n}","preventionTips":["Verify balanced parentheses in type expressions","Prefer programmatic type construction over hand-written type strings","Test schema strings through TypeParser before applying them"],"tags":["type-parser","syntax","schema"],"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"}