{"record":{"id":"8aa86173ae6125d3","repo":"apache/cassandra","slug":"invalid-dc-weighting-syntax-s-use-dc-weight","errorCode":null,"errorMessage":"Invalid dc weighting syntax %s, use <dc>:<weight>","messagePattern":"Invalid dc weighting syntax (.+?), use <dc>:<weight>","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/accord/topology/ParameterizedFastPathStrategy.java","lineNumber":150,"sourceCode":"            int weight = Integer.parseInt(w);\n            if (weight < 0)\n                throw cfe(\"DC weights must be zero or positive\");\n            return weight;\n        }\n\n        static WeightedDc fromString(String s, int idx)\n        {\n            s = s.trim();\n            if (s.isEmpty())\n                throw cfe(\"%s entries must not be empty\", DCS);\n\n            String[] parts = COLON_SEPARATOR.split(s);\n            if (parts.length == 1)\n                return new WeightedDc(validateDC(parts[0]), idx, true);\n            else if (parts.length == 2)\n                return new WeightedDc(validateDC(parts[0]), validateWeight(parts[1]), false);\n            else\n                throw cfe(\"Invalid dc weighting syntax %s, use <dc>:<weight>\", s);\n        }\n    }\n\n    public final int size;\n    private final ImmutableMap<String, WeightedDc> dcs;\n\n    ParameterizedFastPathStrategy(int size, ImmutableMap<String, WeightedDc> dcs)\n    {\n        this.size = size;\n        this.dcs = dcs;\n    }\n\n    public boolean equals(Object o)\n    {\n        if (this == o) return true;\n        if (o == null || getClass() != o.getClass()) return false;\n        ParameterizedFastPathStrategy that = (ParameterizedFastPathStrategy) o;\n        return size == that.size && Objects.equals(dcs, that.dcs);","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/accord/topology/ParameterizedFastPathStrategy.java#L132-L168","documentation":"WeightedDc.fromString throws a ConfigurationException when a dcs entry splits on the colon separator into more than two parts, i.e. it is not of the form <dc> or <dc>:<weight>. The message shows the offending entry and the required '<dc>:<weight>' syntax.","triggerScenarios":"Passing a dcs entry containing multiple colons such as 'dc1:1:2' or a DC name that itself contains a colon (e.g. an IPv6-ish or namespaced name) to the accord parameterized fast_path strategy.","commonSituations":"Operators pasting composite identifiers with colons; accidental double-colon (e.g. 'dc1::2'); confusion with other weight syntaxes (yaml maps) elsewhere in Cassandra config.","solutions":["Rewrite each entry as either '<dc>' or '<dc>:<weight>' with exactly one colon at most","Rename the datacenter to avoid colons, or reference it via a colon-free alias","Validate the list with a regex like ^[^:]+(:\\d+)?$ per entry before applying"],"exampleFix":"// before\n'dcs':'dc1:1:2,dc2'\n\n// after\n'dcs':'dc1:1,dc2'","handlingStrategy":"validation","validationCode":"java.util.regex.Pattern OK = java.util.regex.Pattern.compile(\"^[^:]+(:\\\\d+)?$\");\nfor (String entry : dcs.split(\",\")) {\n    if (!OK.matcher(entry.trim()).matches())\n        throw new IllegalArgumentException(\"entry must be <dc> or <dc>:<weight>: \" + entry);\n}","typeGuard":null,"tryCatchPattern":"try { applyFastPathOption(opts); } catch (org.apache.cassandra.exceptions.ConfigurationException e) {\n    if (e.getMessage().contains(\"use <dc>:<weight>\"))\n        log.error(\"Each dcs entry may contain at most one colon separating dc and weight\");\n}","preventionTips":["Avoid colon-containing datacenter names; use hyphens","Format entries strictly as <dc> or <dc>:<int>","Regex-validate each entry before submitting options","Do not hand-edit serialized asMap output"],"tags":["cassandra","accord","configuration","syntax"],"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-17T15:17:12.973Z"}