{"id":"82c137fffb56bb99","repo":"apache/kafka","slug":"configuration-name-values-must-not-be-empty","errorCode":null,"errorMessage":"Configuration 'name' values must not be empty.","messagePattern":"Configuration 'name' values must not be empty\\.","errorType":"validation","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java","lineNumber":1087,"sourceCode":"                String validString = this.validString.validStrings.isEmpty() ? \"any non-empty value\" : this.validString.toString();\n                throw new ConfigException(\"Configuration '\" + name + \"' must not be empty. Valid values include: \" + validString);\n            }\n\n            if (Set.copyOf(values).size() != values.size()) {\n                throw new ConfigException(\"Configuration '\" + name + \"' values must not be duplicated.\");\n            }\n\n            validateIndividualValues(name, values);\n        }\n\n        private void validateIndividualValues(String name, List<Object> values) {\n            boolean hasValidStrings = !validString.validStrings.isEmpty();\n\n            for (Object value : values) {\n                if (value instanceof String) {\n                    String string = (String) value;\n                    if (string.isEmpty()) {\n                        throw new ConfigException(\"Configuration '\" + name + \"' values must not be empty.\");\n                    }\n                    if (hasValidStrings) {\n                        validString.ensureValid(name, value);\n                    }\n                }\n            }\n        }\n\n        public String toString() {\n            return !validString.validStrings.isEmpty() ? validString.toString() : \"\";\n        }\n    }\n\n    public static class ValidString implements Validator {\n        final List<String> validStrings;\n\n        private ValidString(List<String> validStrings) {\n            this.validStrings = validStrings;","sourceCodeStart":1069,"sourceCodeEnd":1105,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java#L1069-L1105","documentation":"Thrown by ValidList.validateIndividualValues when iterating the elements of a list config and encountering an element that is an empty String. Unlike the top-level 'must not be empty' (which guards the whole list), this guards individual members: a list may be non-empty but still contain \"\" as one of its items, which Kafka treats as invalid.","triggerScenarios":"A ConfigKey using ValidList receives a list like [\"a\", \"\", \"c\"]. Common when the raw value is \"a,,c\" (consecutive/trailing comma) and the split logic yields an empty token. Triggered during ConfigDef.parse() inside the per-element loop in validateIndividualValues.","commonSituations":"Comma-separated configs with stray commas (\"a,,b\"), leading/trailing commas (\",a,b\" or \"a,b,\"), or whitespace-only entries that the splitter collapses to empty. Frequent when properties files are edited by hand or generated by templating systems.","solutions":["Remove empty tokens from the comma-separated value (fix 'a,,b' to 'a,b', drop leading/trailing commas).","Sanitize the raw string before assignment: value.replaceAll(\"(^,|,$|(?<=,),)\", \"\").","If empty elements are intentional in your pipeline, filter them out before passing the list to ConfigDef."],"exampleFix":"// before\nprops.put(\"my.list.config\", \"read,,write,\");\n\n// after\nprops.put(\"my.list.config\", \"read,write\");","handlingStrategy":"validation","validationCode":"// Strip empty strings from list values before constructing the client:\nfor (Map.Entry<String, Object> e : new HashMap<>(props).entrySet()) {\n    if (e.getValue() instanceof List<?>) {\n        List<?> cleaned = ((List<?>) e.getValue()).stream()\n            .filter(el -> !(el instanceof String) || !((String) el).isEmpty())\n            .collect(Collectors.toList());\n        props.put(e.getKey(), cleaned);\n    }\n}","typeGuard":"null","tryCatchPattern":"try {\n    def.parse(props);\n} catch (ConfigException ce) {\n    if (ce.getMessage().endsWith(\"values must not be empty.\")) {\n        stripEmptiesAndRetry(props, ce.getName());\n    } else throw ce;\n}","preventionTips":["When splitting 'a,,b,c' on ',', filter out empty tokens before storing in the props map.","Treat a list containing an empty string as a parser bug in your config loader, not as valid input.","Use a CSV parser that can report empty fields rather than silently emitting them."],"tags":["config","kafka-client","validation","validator","list","empty-string"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}