{"id":"c9ee3d93531d7f97","repo":"apache/kafka","slug":"invalid-value-for-configuration-the-value-c9ee3d","errorCode":null,"errorMessage":"Invalid value `{}` for configuration {}. The value must either be 'implicit' or 'explicit'.","messagePattern":"Invalid value `(.+?)` for configuration (.+?)\\. The value must either be 'implicit' or 'explicit'\\.","errorType":"validation","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareAcknowledgementMode.java","lineNumber":104,"sourceCode":"    public int hashCode() {\n        return Objects.hash(acknowledgementMode);\n    }\n\n    @Override\n    public String toString() {\n        return \"ShareAcknowledgementMode{\" +\n                \"mode=\" + acknowledgementMode +\n                '}';\n    }\n\n    public static class Validator implements ConfigDef.Validator {\n        @Override\n        public void ensureValid(String name, Object value) {\n            String acknowledgementMode = (String) value;\n            try {\n                fromString(acknowledgementMode);\n            } catch (Exception e) {\n                throw new ConfigException(name, value, \"Invalid value `\" + acknowledgementMode + \"` for configuration \" +\n                        name + \". The value must either be 'implicit' or 'explicit'.\");\n            }\n        }\n\n        @Override\n        public String toString() {\n            String values = Arrays.stream(ShareAcknowledgementMode.AcknowledgementMode.values())\n                    .map(ShareAcknowledgementMode.AcknowledgementMode::toString).collect(Collectors.joining(\", \"));\n            return \"[\" + values + \"]\";\n        }\n    }\n}\n","sourceCodeStart":86,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareAcknowledgementMode.java#L86-L117","documentation":"Thrown by ShareAcknowledgementMode.Validator.ensureValid (a ConfigDef.Validator) when the configured value of share.acknowledgement.mode cannot be parsed by fromString(). The validator catches the underlying IllegalArgumentException and rethrows it as a org.apache.kafka.common.config.ConfigException with a human-readable message naming the property and listing the allowed values. This is the user-facing error surfaced during KafkaConsumer construction.","triggerScenarios":"Constructing a KafkaShareConsumer (or any consumer with the share.acknowledgement.mode property) with a missing, mistyped, or otherwise invalid value; passing an empty string; passing a value the validator cannot translate to IMPLICIT/EXPLICIT.","commonSituations":"Typos in config files (\"implict\", \"Explicit \" with whitespace, \"ACK\"); properties loaded from env vars that resolved to empty; migrating configs across Kafka versions where the property name or accepted values changed.","solutions":["Set share.acknowledgement.mode to either \"implicit\" or \"explicit\" (case-insensitive, no surrounding whitespace).","Print the resolved config value at startup to catch env-var substitution issues (empty strings, trailing quotes).","Consult the validator's allowed set via its toString() (\"[implicit, explicit]\") when constructing configs programmatically."],"exampleFix":"# before\nshare.acknowledgement.mode=${ACK_MODE}   # ACK_MODE was unset -> \"\"\n\n# after\nshare.acknowledgement.mode=implicit","handlingStrategy":"validation","validationCode":"// Pre-validate the config value before constructing the KafkaConsumer,\n// using the same Validator the broker/client would apply.\nString mode = props.getProperty(\"share.acknowledgement.mode\");\nnew ShareAcknowledgementMode.Validator().ensureValid(\n    \"share.acknowledgement.mode\", mode);  // throws ConfigException if invalid\n// Safe to build the consumer now.\nKafkaConsumer<byte[], byte[]> consumer = new KafkaConsumer<>(props);","typeGuard":"java.util.function.Predicate<String> isValidAckMode = s ->\n    s != null && java.util.Set.of(\"implicit\", \"explicit\")\n        .contains(s.trim().toLowerCase(java.util.Locale.ROOT));","tryCatchPattern":"try {\n    KafkaConsumer<byte[], byte[]> consumer = new KafkaConsumer<>(props);\n} catch (org.apache.kafka.common.config.ConfigException ex) {\n    // Configuration value for share.acknowledgement.mode was invalid;\n    // correct the property and retry construction.\n    if (ex.getMessage().contains(\"share.acknowledgement.mode\")) {\n        props.put(\"share.acknowledgement.mode\", \"implicit\");\n    } else {\n        throw ex;\n    }\n}","preventionTips":["Set share.acknowledgement.mode explicitly in your config map to one of 'implicit' or 'explicit'.","Run the client's ConfigDef Validator during config loading (CI/startup) so bad values fail before runtime.","Keep config in a typed structure (enum or sealed type) rather than raw Strings once parsed.","Catch ConfigException at consumer construction and report which property failed, not just the message."],"tags":["share-consumer","config","validation","startup"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}