quarkusio/quarkus · error · IllegalArgumentException

Entry with empty key <entry>

Error message

Entry with empty key <entry>

What it means

ToolsUtils.stringToMap parses a delimited string into a key/value map. If any entry has a blank key (empty text before the key/value separator, or an empty segment), it throws IllegalArgumentException('Entry with empty key <entry>') rather than silently storing a bogus mapping.

Source

Thrown at independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsUtils.java:56

        return value;
    }

    public static String getProperty(String name) {
        return getProperty(name, null);
    }

    public static String getProperty(String name, String defaultValue) {
        return System.getProperty(name, defaultValue);
    }

    public static Map<String, String> stringToMap(
            String str, String entrySeparator, String keyValueSeparator) {
        HashMap<String, String> result = new HashMap<>();
        for (String entry : StringUtils.splitByWholeSeparator(str, entrySeparator)) {
            String[] pair = StringUtils.splitByWholeSeparator(entry, keyValueSeparator, 2);

            if (pair.length > 0 && StringUtils.isBlank(pair[0])) {
                throw new IllegalArgumentException("Entry with empty key " + entry);
            }

            switch (pair.length) {
                case 1:
                    result.put(pair[0].trim(), "");
                    break;
                case 2:
                    result.put(pair[0].trim(), pair[1].trim());
                    break;
            }
        }

        return result;
    }

    public static boolean isNullOrEmpty(String arg) {
        return arg == null || arg.isEmpty();
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove empty segments and stray separators from the input string
  2. Validate/split the input before passing it, skipping blank entries
  3. Fix the code producing the string so it does not emit trailing/doubled separators

Example fix

// before
String s = "k1=v1;;k2=v2"; // blank entry -> IllegalArgumentException
// after
String s = "k1=v1;k2=v2";
Defensive patterns

Strategy: validation

Validate before calling

static boolean parseableMap(String s, String entrySep, String kvSep) {
    if (s == null || s.isBlank()) return true;
    for (String e : s.split(java.util.regex.Pattern.quote(entrySep))) {
        String[] pair = e.split(java.util.regex.Pattern.quote(kvSep), 2);
        if (pair.length > 0 && pair[0].isBlank()) return false;
    }
    return true;
}

Try / catch

try {
    Map<String, String> m = ToolsUtils.stringToMap(str, ";", "=");
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Entry with empty key")) {
        str = Arrays.stream(str.split(";")).filter(t -> !t.isBlank())
                .collect(Collectors.joining(";")); // strip empty segments and retry
        Map<String, String> m2 = ToolsUtils.stringToMap(str, ";", "=");
    } else throw e;
}

Prevention

When it happens

Trigger: Passing a string containing empty entries or entries starting with the key/value separator — e.g. "k1=v1;;k2=v2" (double entry separator), "=value", ",k=v" — to stringToMap.

Common situations: User-provided config strings (registry lists, header maps) with trailing commas/semicolons; environment variables built by concatenation leaving stray separators; copy-pasted config with doubled delimiters.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/e9b91272f88cc23b. Report an issue: GitHub.