{"record":{"id":"fdbebaf4ec3971cd","repo":"apache/cassandra","slug":"could-not-parse-tokenkey-vs-i","errorCode":null,"errorMessage":"Could not parse TokenKey \" + vs[i]","messagePattern":"Could not parse TokenKey \" \\+ vs\\[i\\]","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java","lineNumber":2572,"sourceCode":"    }\n\n    public static Participants<?> parseParticipants(Object input)\n    {\n        if (input == null)\n            return null;\n\n        String str = (String) input;\n        if (str.isEmpty())\n            return RoutingKeys.EMPTY;\n\n        String[] vs = str.split(\"\\\\|\");\n        if (!vs[0].endsWith(\"]\"))\n        {\n            RoutingKey[] keys = new RoutingKey[vs.length];\n            for (int i = 0 ; i < keys.length ; ++i)\n            {\n                try { keys[i] = TokenKey.parse(vs[i], DatabaseDescriptor.getPartitioner()); }\n                catch (Throwable t) { throw new InvalidRequestException(\"Could not parse TokenKey \" + vs[i]); }\n            }\n            return RoutingKeys.of(keys);\n        }\n        else\n        {\n            TokenRange[] ranges = new TokenRange[vs.length];\n            for (int i = 0 ; i < ranges.length ; ++i)\n            {\n                try { ranges[i] = TokenRange.parse(vs[i], DatabaseDescriptor.getPartitioner()); }\n                catch (Throwable t) { throw new InvalidRequestException(\"Could not parse TokenKey \" + vs[i]); }\n            }\n            return Ranges.of(ranges);\n        }\n    }\n\n    public static String toString(Participants<?> participants)\n    {\n        StringBuilder out = new StringBuilder();","sourceCodeStart":2554,"sourceCodeEnd":2590,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java#L2554-L2590","documentation":"When parsing a routing-keys/token-list string from an Accord debug table, each comma-separated token that does not end the range syntax ('...]' style) is parsed as a TokenKey with the cluster partitioner. Any parse failure is rethrown as an InvalidRequestException identifying the specific token that could not be parsed.","triggerScenarios":"Supplying a token key list column value where one of the individual token components (vs[i]) is not a valid token literal for the configured partitioner — e.g. malformed numeric token, stray characters, or a token from a different partitioner format.","commonSituations":"Hand-editing token ranges copied from another cluster with a different partitioner (Murmur3 vs Random vs ByteOrdered); truncating a copied list mid-token; mixing range syntax '[..]' with bare tokens incorrectly so a range fragment lands in the bare-token branch.","solutions":["Fix the offending token to be a valid literal for DatabaseDescriptor's partitioner (e.g. a plain signed long for Murmur3Token)","Verify the whole string uses one consistent syntax: bare tokens for RoutingKeys, or full '[...]' range syntax for TokenRange","Copy token keys directly from system tables (e.g. system.local or ring output) instead of hand-writing them"],"exampleFix":"// before\nUPDATE system.accord_debug SET token_keys = '-9223372036854775808, 12a3';\n// after\nUPDATE system.accord_debug SET token_keys = '-9223372036854775808, 123'; // each token must parse with the cluster partitioner","handlingStrategy":"validation","validationCode":"// each bare component must parse with the cluster partitioner before sending\nfor (String part : value.split(\",\")) {\n    if (!part.trim().endsWith(\"]\")) {\n        try { TokenKey.parse(part.trim(), DatabaseDescriptor.getPartitioner()); }\n        catch (Throwable t) { throw new IllegalArgumentException(\"bad TokenKey: \" + part); }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    session.execute(update);\n} catch (InvalidRequestException e) {\n    if (e.getMessage().startsWith(\"Could not parse TokenKey\")) {\n        // fix the specific token echoed in the message and retry\n    }\n}","preventionTips":["Copy token literals from system/ring output instead of typing them","Ensure the partitioner matches the source of the tokens (Murmur3 vs Random)","Keep list syntax consistent: all bare tokens, or all '[...]' ranges — no fragments"],"tags":["cassandra","cql","parsing","token"],"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"}