{"record":{"id":"e8c3d0dc3e8e2235","repo":"apache/cassandra","slug":"invalid-token-for-murmur3partitioner-got-s-but-e","errorCode":null,"errorMessage":"Invalid token for Murmur3Partitioner. Got %s but expected a long value (unsigned 8 bytes integer).","messagePattern":"Invalid token for Murmur3Partitioner\\. Got (.+?) but expected a long value \\(unsigned 8 bytes integer\\)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/dht/Murmur3Partitioner.java","lineNumber":557,"sourceCode":"            try\n            {\n                fromString(token);\n            }\n            catch (NumberFormatException e)\n            {\n                throw new ConfigurationException(e.getMessage());\n            }\n        }\n\n        public Token fromString(String string)\n        {\n            try\n            {\n                return new LongToken(Long.parseLong(string));\n            }\n            catch (NumberFormatException e)\n            {\n                throw new IllegalArgumentException(String.format(\"Invalid token for Murmur3Partitioner. Got %s but expected a long value (unsigned 8 bytes integer).\", string));\n            }\n        }\n    };\n\n    public AbstractType<?> getTokenValidator()\n    {\n        return LongType.instance;\n    }\n\n    public Token getMaximumTokenForSplitting()\n    {\n        return new LongToken(Long.MAX_VALUE);\n    }\n\n    public AbstractType<?> partitionOrdering()\n    {\n        return partitionOrdering;\n    }","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/dht/Murmur3Partitioner.java#L539-L575","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Provide a decimal integer within the signed 64-bit range, e.g. -9223372036854775808 to 9223372036854775807.","Wrap the value in a try-catch for IllegalArgumentException if input is user-supplied, and surface a clear validation message before calling fromString.","Regenerate the token for Murmur3Partitioner (do not reuse tokens from other partitioners).","Pre-validate with a regex like ^-?\\d+$ plus a Long.parseLong check before invoking the factory."],"exampleFix":"// before\nToken t = Murmur3Partitioner.instance.getTokenFactory().fromString(\"18446744073709551615\"); // unsigned max, overflows long\n// after\nlong value = Long.parseUnsignedLong(\"18446744073709551615\"); // then check range, or simply use a valid long:\nToken t = Murmur3Partitioner.instance.getTokenFactory().fromString(\"-9223372036854775808\");","handlingStrategy":"validation","validationCode":"private static final Pattern LONG = Pattern.compile(\"^-?\\\\d{1,19}$\");\npublic static boolean isValidMurmur3Token(String s) {\n    if (s == null || !LONG.matcher(s).matches()) return false;\n    try { Long.parseLong(s); return true; } catch (NumberFormatException e) { return false; }\n}","typeGuard":"boolean isLongToken(String s) { try { Long.parseLong(s); return true; } catch (NumberFormatException | NullPointerException e) { return false; } }","tryCatchPattern":"try {\n    Token t = factory.fromString(input);\n} catch (IllegalArgumentException e) {\n    throw new IllegalArgumentException(\"Murmur3 tokens must be a signed 64-bit decimal long\", e);\n}","preventionTips":["Validate token strings with Long.parseLong before calling fromString.","Remember Murmur3 tokens are signed longs; values above Long.MAX_VALUE are invalid.","Never reuse tokens from other partitioners."],"tags":["token","murmur3","parsing","invalid-argument"],"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"}