apache/cassandra · error · InvalidRequestException
Could not parse TokenKey " + vs[i]
Error message
Could not parse TokenKey " + vs[i]
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java:2572
}
public static Participants<?> parseParticipants(Object input)
{
if (input == null)
return null;
String str = (String) input;
if (str.isEmpty())
return RoutingKeys.EMPTY;
String[] vs = str.split("\\|");
if (!vs[0].endsWith("]"))
{
RoutingKey[] keys = new RoutingKey[vs.length];
for (int i = 0 ; i < keys.length ; ++i)
{
try { keys[i] = TokenKey.parse(vs[i], DatabaseDescriptor.getPartitioner()); }
catch (Throwable t) { throw new InvalidRequestException("Could not parse TokenKey " + vs[i]); }
}
return RoutingKeys.of(keys);
}
else
{
TokenRange[] ranges = new TokenRange[vs.length];
for (int i = 0 ; i < ranges.length ; ++i)
{
try { ranges[i] = TokenRange.parse(vs[i], DatabaseDescriptor.getPartitioner()); }
catch (Throwable t) { throw new InvalidRequestException("Could not parse TokenKey " + vs[i]); }
}
return Ranges.of(ranges);
}
}
public static String toString(Participants<?> participants)
{
StringBuilder out = new StringBuilder();View on GitHub (pinned to 88fd0f6a0e)
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
Example fix
// before UPDATE system.accord_debug SET token_keys = '-9223372036854775808, 12a3'; // after UPDATE system.accord_debug SET token_keys = '-9223372036854775808, 123'; // each token must parse with the cluster partitioner
Defensive patterns
Strategy: validation
Validate before calling
// each bare component must parse with the cluster partitioner before sending
for (String part : value.split(",")) {
if (!part.trim().endsWith("]")) {
try { TokenKey.parse(part.trim(), DatabaseDescriptor.getPartitioner()); }
catch (Throwable t) { throw new IllegalArgumentException("bad TokenKey: " + part); }
}
} Try / catch
try {
session.execute(update);
} catch (InvalidRequestException e) {
if (e.getMessage().startsWith("Could not parse TokenKey")) {
// fix the specific token echoed in the message and retry
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Unknown " + clazz.getName() + ": '" + input + "'
- category %s not found in %s
- GRANT operation is not supported by AllowAllAuthorizer
- REVOKE operation is not supported by AllowAllAuthorizer
- LIST PERMISSIONS operation is not supported by AllowAllAutho
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/fdbebaf4ec3971cd.
Report an issue: GitHub.