{"record":{"id":"94b3660bc5a7d4b5","repo":"apache/cassandra","slug":"tokens-may-not-contain-the-character-versioned","errorCode":null,"errorMessage":"Tokens may not contain the character \" + VersionedValue.DELIMITER_STR","messagePattern":"Tokens may not contain the character \" \\+ VersionedValue\\.DELIMITER_STR","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java","lineNumber":201,"sourceCode":"            {\n                return new StringToken(ByteBufferUtil.string(bytes));\n            }\n            catch (CharacterCodingException e)\n            {\n                throw new RuntimeException(e);\n            }\n        }\n\n        public String toString(Token token)\n        {\n            StringToken stringToken = (StringToken) token;\n            return stringToken.token;\n        }\n\n        public void validate(String token) throws ConfigurationException\n        {\n            if (token.contains(VersionedValue.DELIMITER_STR))\n                throw new ConfigurationException(\"Tokens may not contain the character \" + VersionedValue.DELIMITER_STR);\n        }\n\n        public Token fromString(String string)\n        {\n            return new StringToken(string);\n        }\n    };\n\n    public Token.TokenFactory getTokenFactory()\n    {\n        return tokenFactory;\n    }\n\n    public boolean preservesOrder()\n    {\n        return true;\n    }\n","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java#L183-L219","documentation":"OrderPreservingPartitioner tokens are UTF-8 strings, and Gossip's VersionedValue uses '|' as a delimiter inside gossip state. A token string containing the delimiter would corrupt gossip encoding, so TokenFactory.validate rejects any token containing VersionedValue.DELIMITER_STR ('|') with a ConfigurationException.","triggerScenarios":"Calling OrderPreservingPartitioner.getTokenFactory().validate(token) (e.g. when loading initial_token from cassandra.yaml or validating user input) with a token containing the '|' character.","commonSituations":"initial_token in cassandra.yaml containing a pipe (paths, regexes, or UUID-like strings with separators pasted as tokens); scripting token generation on a legacy OPP cluster without filtering the delimiter.","solutions":["Remove or replace the '|' character in the token string before assigning it as initial_token.","Add pre-validation in your token-generation script: reject tokens containing '|'.","Prefer switching to Murmur3Partitioner — OrderPreservingPartitioner is legacy and string tokens have this and other restrictions.","If calling validate() in code, catch ConfigurationException and re-prompt/re-derive the token."],"exampleFix":"// before\nString token = \"abc|def\"; // contains gossip delimiter\nfactory.validate(token); // throws\n// after\nString token = rawToken.replace(\"|\", \"\");\nif (!token.contains(VersionedValue.DELIMITER_STR)) factory.validate(token);","handlingStrategy":"validation","validationCode":"public static boolean isValidOppToken(String token) {\n    return token != null && !token.isEmpty() && !token.contains(VersionedValue.DELIMITER_STR);\n}","typeGuard":"boolean gossipSafeToken(String t) { return !t.contains(\"|\"); }","tryCatchPattern":"try {\n    factory.validate(token);\n} catch (ConfigurationException e) {\n    throw new IllegalArgumentException(\"Token must not contain the gossip delimiter '|' \", e);\n}","preventionTips":["Reject '|' in tokens at input time in any token generation tooling.","Sanitize initial_token values in cassandra.yaml during config linting.","Consider migrating off OrderPreservingPartitioner to avoid legacy string-token restrictions."],"tags":["token","validation","gossip","order-preserving-partitioner"],"backgroundTag":"invalid-config-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}