{"record":{"id":"a9cffb1eec26fe9c","repo":"apache/cassandra","slug":"s-must-specify-at-least-one-dc","errorCode":null,"errorMessage":"%s must specify at least one DC","messagePattern":"(.+?) must specify at least one DC","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/accord/topology/ParameterizedFastPathStrategy.java","lineNumber":265,"sourceCode":"        try\n        {\n            size = Integer.parseInt(map.get(SIZE));\n        }\n        catch (NumberFormatException e)\n        {\n            throw cfe(\"%s must be a positive number, got %s\", SIZE, map.get(SIZE));\n        }\n\n        if (size < 1)\n            throw cfe(\"%s must be greater than zero\", SIZE);\n\n        ImmutableMap<String, WeightedDc> dcMap;\n        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\");","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/accord/topology/ParameterizedFastPathStrategy.java#L247-L283","documentation":"fromMap() requires that the 'dcs' option, when present and non-empty in the map, contains at least one datacenter name after trimming whitespace. An all-whitespace value passes the initial isEmpty() check but fails the trim() check, so it is rejected with a ConfigurationException.","triggerScenarios":"Calling fromMap() with {\"dcs\": \"   \"} or {\"dcs\": \"\\t\"} — a key present and non-empty whose trimmed content is empty.","commonSituations":"Clearing the DC list in configuration by replacing it with whitespace; templating systems emitting an empty-but-present dcs string.","solutions":["Provide at least one DC, e.g. {\"dcs\": \"dc1\"}","Remove the 'dcs' key entirely if no DC restrictions are intended","Strip/normalize the configured string before calling fromMap() and omit the key if blank"],"exampleFix":"// before\nMap<String,String> opts = Map.of(\"dcs\", \"  \");\nParameterizedFastPathStrategy.fromMap(opts); // throws\n// after\nMap<String,String> opts = Map.of(\"dcs\", \"dc1,dc2\");\nParameterizedFastPathStrategy.fromMap(opts); // ok","handlingStrategy":"validation","validationCode":"String dcs = map.get(\"dcs\");\nif (dcs != null && !dcs.isEmpty() && dcs.trim().isEmpty())\n    throw new IllegalArgumentException(\"dcs, when set, must name at least one DC\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat blank strings as 'unset' in your config pipeline and strip the key","Watch for templates emitting whitespace-only values where lists are expected"],"tags":["configuration","validation","accord"],"backgroundTag":"empty-required-field","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"}