{"id":"c98e310eef38a879","repo":"apache/kafka","slug":"configuration-name-must-not-be-empty-valid-valu","errorCode":null,"errorMessage":"Configuration 'name' must not be empty. Valid values include: validString","messagePattern":"Configuration 'name' must not be empty\\. Valid values include: validString","errorType":"validation","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java","lineNumber":1070,"sourceCode":"                throw new IllegalArgumentException(\"At least one valid string must be provided when empty values are not allowed\");\n            }\n            return new ValidList(List.of(validStrings), isEmptyAllowed, false);\n        }\n\n        @Override\n        public void ensureValid(final String name, final Object value) {\n            if (value == null) {\n                if (isNullAllowed)\n                    return;\n                else\n                    throw new ConfigException(\"Configuration '\" + name + \"' values must not be null.\");\n            }\n\n            @SuppressWarnings(\"unchecked\")\n            List<Object> values = (List<Object>) value;\n            if (!isEmptyAllowed && values.isEmpty()) {\n                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                    }","sourceCodeStart":1052,"sourceCodeEnd":1088,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java#L1052-L1088","documentation":"Thrown by ValidList.ensureValid when the supplied list is empty and the validator was built with isEmptyAllowed=false (via ValidList.in(boolean, String...)). Kafka rejects empty lists here because the config requires at least one element; the message appends either the allowed value set or 'any non-empty value' when the validator constrains only count, not contents.","triggerScenarios":"Calling ConfigDef.parse()/validate() on properties where the named list config resolves to an empty list (e.g. value \"\" split into [], or an explicit empty Collections.emptyList()) while the ConfigKey was defined with ValidList.in(false, ...) or ValidList.anyNonDuplicateValues(false, isNullAllowed).","commonSituations":"Comma-separated list configs (e.g. custom interceptor.classes, or broker/listener configs using list validators) configured with an empty string in server.properties or a properties file. Also seen when a templated deployment leaves a list placeholder blank.","solutions":["Supply at least one valid element for the named list config (e.g. change \"my.list=\" to \"my.list=value1\").","Confirm each element is one of the validStrings printed in the message when the validator enumerates allowed values.","If an empty list is genuinely acceptable, change the ConfigKey definition to ValidList.in(true, ...) or anyNonDuplicateValues(true, isNullAllowed)."],"exampleFix":"// before\nprops.put(\"my.list.config\", \"\");\n\n// after\nprops.put(\"my.list.config\", \"read,write\");","handlingStrategy":"validation","validationCode":"// Ensure a non-empty list is supplied for every config defined with ValidList.in(false, ...):\nfor (String requiredListKey : List.of(\"bootstrap.servers\", \"sasl.kerberos.principal\" /* etc. */)) {\n    Object v = configs.get(requiredListKey);\n    if (v instanceof List<?> && ((List<?>) v).isEmpty()) {\n        throw new IllegalArgumentException(\"Config '\" + requiredListKey + \"' must not be empty.\");\n    }\n}","typeGuard":"null","tryCatchPattern":"try {\n    ConfigDef def = ...; // the producer/consumer ConfigDef\n    def.parse(props);\n} catch (ConfigException ce) {\n    if (ce.getMessage().contains(\"must not be empty\")) {\n        // surface to operator with the list of valid values printed in ce.getMessage()\n        reportMissingRequired(ce);\n    } else throw ce;\n}","preventionTips":["Provide a non-empty default in your own config layer for list-typed Kafka settings.","If the source is user input (env var, CLI), split and reject empty results before assigning to the props map.","Validate list sizes against the documented ValidList.in(...) contract of each Kafka config key."],"tags":["config","kafka-client","validation","validator","list"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}