apache/cassandra · error · IllegalArgumentException

Invalid token for Murmur3Partitioner. Got %s but expected a

Error message

Invalid token for Murmur3Partitioner. Got %s but expected a long value (unsigned 8 bytes integer).

What it means

Murmur3Partitioner's TokenFactory.fromString parses the token string with Long.parseLong and converts NumberFormatException into IllegalArgumentException stating that Murmur3 tokens must be a long value. Murmur3 tokens are 64-bit signed longs, so any string outside that format is rejected.

Source

Thrown at src/java/org/apache/cassandra/dht/Murmur3Partitioner.java:557

            try
            {
                fromString(token);
            }
            catch (NumberFormatException e)
            {
                throw new ConfigurationException(e.getMessage());
            }
        }

        public Token fromString(String string)
        {
            try
            {
                return new LongToken(Long.parseLong(string));
            }
            catch (NumberFormatException e)
            {
                throw new IllegalArgumentException(String.format("Invalid token for Murmur3Partitioner. Got %s but expected a long value (unsigned 8 bytes integer).", string));
            }
        }
    };

    public AbstractType<?> getTokenValidator()
    {
        return LongType.instance;
    }

    public Token getMaximumTokenForSplitting()
    {
        return new LongToken(Long.MAX_VALUE);
    }

    public AbstractType<?> partitionOrdering()
    {
        return partitionOrdering;
    }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Provide a decimal integer within the signed 64-bit range, e.g. -9223372036854775808 to 9223372036854775807.
  2. Wrap the value in a try-catch for IllegalArgumentException if input is user-supplied, and surface a clear validation message before calling fromString.
  3. Regenerate the token for Murmur3Partitioner (do not reuse tokens from other partitioners).
  4. Pre-validate with a regex like ^-?\d+$ plus a Long.parseLong check before invoking the factory.

Example fix

// before
Token t = Murmur3Partitioner.instance.getTokenFactory().fromString("18446744073709551615"); // unsigned max, overflows long
// after
long value = Long.parseUnsignedLong("18446744073709551615"); // then check range, or simply use a valid long:
Token t = Murmur3Partitioner.instance.getTokenFactory().fromString("-9223372036854775808");
Defensive patterns

Strategy: validation

Validate before calling

private static final Pattern LONG = Pattern.compile("^-?\\d{1,19}$");
public static boolean isValidMurmur3Token(String s) {
    if (s == null || !LONG.matcher(s).matches()) return false;
    try { Long.parseLong(s); return true; } catch (NumberFormatException e) { return false; }
}

Type guard

boolean isLongToken(String s) { try { Long.parseLong(s); return true; } catch (NumberFormatException | NullPointerException e) { return false; } }

Try / catch

try {
    Token t = factory.fromString(input);
} catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("Murmur3 tokens must be a signed 64-bit decimal long", e);
}

Prevention

When it happens

Trigger: Calling Murmur3Partitioner.getTokenFactory().fromString(s) with a non-numeric string, a value above Long.MAX_VALUE, an unsigned 64-bit value beyond the signed range, or a token copied from another partitioner (hex string, UUID, text).

Common situations: Hand-setting initial_token with a decimal copied from a ByteOrderedPartitioner cluster; entering a value like 18446744073709551615 (unsigned 8-byte, exceeding Long.MAX_VALUE); typos when scripting nodetool/CQL system.peers token updates.

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/e8c3d0dc3e8e2235. Report an issue: GitHub.