{"record":{"id":"11af310d44356db7","repo":"apache/cassandra","slug":"cannot-mix-auto-and-manual-dc-weights","errorCode":null,"errorMessage":"Cannot mix auto and manual DC weights","messagePattern":"Cannot mix auto and manual DC weights","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/accord/topology/ParameterizedFastPathStrategy.java","lineNumber":278,"sourceCode":"        if (map.containsKey(DCS) && !map.get(DCS).isEmpty())\n        {\n            Map<String, WeightedDc> mutableDcs = new HashMap<>();\n            String dcsString = map.get(DCS);\n            if (dcsString.trim().isEmpty())\n                throw cfe(\"%s must specify at least one DC\", DCS);\n\n            int autoIdx = 0;\n            boolean hasAuto = false;\n            boolean hasManual = false;\n            for (String dcString : COMMA_SEPARATOR.split(dcsString))\n            {\n                WeightedDc dc = WeightedDc.fromString(dcString, autoIdx++);\n                if (mutableDcs.containsKey(dc.name))\n                    throw cfe(\"Multiple entries for DC %s\", dc.name);\n\n                if (dc.autoWeight)\n                {\n                    if (hasManual) throw cfe(\"Cannot mix auto and manual DC weights\");\n                    hasAuto = true;\n                }\n                else\n                {\n                    if (hasAuto) throw cfe(\"Cannot mix auto and manual DC weights\");\n                    hasManual = true;\n                }\n\n                mutableDcs.put(dc.name, dc);\n            }\n            dcMap = ImmutableMap.copyOf(mutableDcs);\n        }\n        else\n        {\n            dcMap = ImmutableMap.of();\n        }\n\n        Set<String> keys = new HashSet<>(map.keySet());","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/accord/topology/ParameterizedFastPathStrategy.java#L260-L296","documentation":"Each DC entry in 'dcs' either has an explicit weight (manual) or uses an automatic weight. The parser tracks hasAuto/hasManual flags and rejects a list that mixes automatic and manually weighted DCs, because the two sizing semantics are incompatible within one strategy.","triggerScenarios":"Calling fromMap() with a dcs string combining weighted and unweighted entries, e.g. {\"dcs\": \"dc1=0.5,dc2\"} — a manual entry followed by an auto entry.","commonSituations":"Adding a new DC with explicit weight to an existing list of unweighted DCs (or vice versa); partial migration from auto weighting to manual weights during an operational change.","solutions":["Give every DC an explicit weight (e.g. \"dc1=1.0,dc2=2.0\") for fully manual weighting","Remove all '=weight' suffixes for fully automatic weighting","Split strategies if different DCs genuinely need different semantics — one strategy cannot mix them"],"exampleFix":"// before\nMap<String,String> opts = Map.of(\"dcs\", \"dc1=0.5,dc2\");\nParameterizedFastPathStrategy.fromMap(opts); // throws\n// after\nMap<String,String> opts = Map.of(\"dcs\", \"dc1=0.5,dc2=1.0\");\nParameterizedFastPathStrategy.fromMap(opts); // ok","handlingStrategy":"validation","validationCode":"long weighted = dcsList.stream().filter(s -> s.contains(\"=\")).count();\nif (weighted != 0 && weighted != dcsList.size())\n    throw new IllegalArgumentException(\"all DCs must be either weighted or unweighted\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one weighting model (all-auto or all-manual) per strategy","When adding a DC to an existing list, match the weighting style of existing entries"],"tags":["configuration","validation","accord"],"backgroundTag":"mutually-exclusive-options","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"}