{"record":{"id":"e9b91272f88cc23b","repo":"quarkusio/quarkus","slug":"entry-with-empty-key-entry","errorCode":null,"errorMessage":"Entry with empty key <entry>","messagePattern":"Entry with empty key <entry>","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsUtils.java","lineNumber":56,"sourceCode":"        return value;\n    }\n\n    public static String getProperty(String name) {\n        return getProperty(name, null);\n    }\n\n    public static String getProperty(String name, String defaultValue) {\n        return System.getProperty(name, defaultValue);\n    }\n\n    public static Map<String, String> stringToMap(\n            String str, String entrySeparator, String keyValueSeparator) {\n        HashMap<String, String> result = new HashMap<>();\n        for (String entry : StringUtils.splitByWholeSeparator(str, entrySeparator)) {\n            String[] pair = StringUtils.splitByWholeSeparator(entry, keyValueSeparator, 2);\n\n            if (pair.length > 0 && StringUtils.isBlank(pair[0])) {\n                throw new IllegalArgumentException(\"Entry with empty key \" + entry);\n            }\n\n            switch (pair.length) {\n                case 1:\n                    result.put(pair[0].trim(), \"\");\n                    break;\n                case 2:\n                    result.put(pair[0].trim(), pair[1].trim());\n                    break;\n            }\n        }\n\n        return result;\n    }\n\n    public static boolean isNullOrEmpty(String arg) {\n        return arg == null || arg.isEmpty();\n    }","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsUtils.java#L38-L74","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove empty segments and stray separators from the input string","Validate/split the input before passing it, skipping blank entries","Fix the code producing the string so it does not emit trailing/doubled separators"],"exampleFix":"// before\nString s = \"k1=v1;;k2=v2\"; // blank entry -> IllegalArgumentException\n// after\nString s = \"k1=v1;k2=v2\";","handlingStrategy":"validation","validationCode":"static boolean parseableMap(String s, String entrySep, String kvSep) {\n    if (s == null || s.isBlank()) return true;\n    for (String e : s.split(java.util.regex.Pattern.quote(entrySep))) {\n        String[] pair = e.split(java.util.regex.Pattern.quote(kvSep), 2);\n        if (pair.length > 0 && pair[0].isBlank()) return false;\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":"try {\n    Map<String, String> m = ToolsUtils.stringToMap(str, \";\", \"=\");\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Entry with empty key\")) {\n        str = Arrays.stream(str.split(\";\")).filter(t -> !t.isBlank())\n                .collect(Collectors.joining(\";\")); // strip empty segments and retry\n        Map<String, String> m2 = ToolsUtils.stringToMap(str, \";\", \"=\");\n    } else throw e;\n}","preventionTips":["Sanitize user-provided delimited config strings (drop empty segments) before parsing","Avoid building such strings by naive concatenation; join non-empty parts","Validate config early at startup with clear error messages"],"tags":["parsing","configuration","illegal-argument"],"backgroundTag":"malformed-key-value-pair","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}