apache/cassandra · error · ConfigurationException

%s must specify at least one DC

Error message

%s must specify at least one DC

What it means

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.

Source

Thrown at src/java/org/apache/cassandra/service/accord/topology/ParameterizedFastPathStrategy.java:265

        try
        {
            size = Integer.parseInt(map.get(SIZE));
        }
        catch (NumberFormatException e)
        {
            throw cfe("%s must be a positive number, got %s", SIZE, map.get(SIZE));
        }

        if (size < 1)
            throw cfe("%s must be greater than zero", SIZE);

        ImmutableMap<String, WeightedDc> dcMap;
        if (map.containsKey(DCS) && !map.get(DCS).isEmpty())
        {
            Map<String, WeightedDc> mutableDcs = new HashMap<>();
            String dcsString = map.get(DCS);
            if (dcsString.trim().isEmpty())
                throw cfe("%s must specify at least one DC", DCS);

            int autoIdx = 0;
            boolean hasAuto = false;
            boolean hasManual = false;
            for (String dcString : COMMA_SEPARATOR.split(dcsString))
            {
                WeightedDc dc = WeightedDc.fromString(dcString, autoIdx++);
                if (mutableDcs.containsKey(dc.name))
                    throw cfe("Multiple entries for DC %s", dc.name);

                if (dc.autoWeight)
                {
                    if (hasManual) throw cfe("Cannot mix auto and manual DC weights");
                    hasAuto = true;
                }
                else
                {
                    if (hasAuto) throw cfe("Cannot mix auto and manual DC weights");

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Provide at least one DC, e.g. {"dcs": "dc1"}
  2. Remove the 'dcs' key entirely if no DC restrictions are intended
  3. Strip/normalize the configured string before calling fromMap() and omit the key if blank

Example fix

// before
Map<String,String> opts = Map.of("dcs", "  ");
ParameterizedFastPathStrategy.fromMap(opts); // throws
// after
Map<String,String> opts = Map.of("dcs", "dc1,dc2");
ParameterizedFastPathStrategy.fromMap(opts); // ok
Defensive patterns

Strategy: validation

Validate before calling

String dcs = map.get("dcs");
if (dcs != null && !dcs.isEmpty() && dcs.trim().isEmpty())
    throw new IllegalArgumentException("dcs, when set, must name at least one DC");

Prevention

When it happens

Trigger: Calling fromMap() with {"dcs": " "} or {"dcs": "\t"} — a key present and non-empty whose trimmed content is empty.

Common situations: Clearing the DC list in configuration by replacing it with whitespace; templating systems emitting an empty-but-present dcs string.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/a9cffb1eec26fe9c. Report an issue: GitHub.