{"record":{"id":"6a94b568c0e6b180","repo":"apache/kafka","slug":"cannot-be-set-when-using-a-share-group","errorCode":null,"errorMessage":"{} cannot be set when using a share group.","messagePattern":"(.+?) cannot be set when using a share group\\.","errorType":"validation","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/consumer/ShareConsumerConfig.java","lineNumber":72,"sourceCode":"    protected ShareConsumerConfig(Map<?, ?> props, boolean doLog) {\n        super(props, doLog);\n    }\n\n    @Override\n    protected Map<String, Object> preProcessParsedConfig(final Map<String, Object> parsedValues) {\n        checkUnsupportedConfigsPreProcess(parsedValues);\n        return parsedValues;\n    }\n\n    private void checkUnsupportedConfigsPreProcess(Map<String, Object> parsedValues) {\n        List<String> invalidConfigs = new ArrayList<>();\n        SHARE_GROUP_UNSUPPORTED_CONFIGS.forEach(configName -> {\n            if (parsedValues.containsKey(configName)) {\n                invalidConfigs.add(configName);\n            }\n        });\n        if (!invalidConfigs.isEmpty()) {\n            throw new ConfigException(String.join(\", \", invalidConfigs) +\n                    \" cannot be set when using a share group.\");\n        }\n    }\n\n    @Override\n    protected void checkUnsupportedConfigsPostProcess() {\n    }\n}\n","sourceCodeStart":54,"sourceCodeEnd":81,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/clients/src/main/java/org/apache/kafka/clients/consumer/ShareConsumerConfig.java#L54-L81","documentation":"ShareConsumerConfig rejects a fixed list of consumer configs that are meaningless for share groups: auto.offset.reset, enable.auto.commit, group.instance.id, isolation.level, partition.assignment.strategy, interceptor.classes, session.timeout.ms, heartbeat.interval.ms, group.protocol, and group.remote.assignor. The check runs in preProcessParsedConfig during construction and aggregates all violations into one ConfigException message joined by commas.","triggerScenarios":"Constructing a KafkaShareConsumer (or ShareConsumerConfig) with a Properties/Map containing any of those keys, e.g. setting enable.auto.commit=true alongside group.id and bootstrap.servers for a share consumer.","commonSituations":"Copy-pasting a KafkaConsumer properties file for a share consumer; migrating an application to share groups without pruning incompatible settings; libraries that auto-set partition.assignment.strategy.","solutions":["Remove the listed config keys from the properties passed to the share consumer (auto.offset.reset, enable.auto.commit, group.instance.id, isolation.level, partition.assignment.strategy, interceptor.classes, session.timeout.ms, heartbeat.interval.ms, group.protocol, group.remote.assignor).","If you must keep a shared config file, branch at runtime: build one Properties for the classic consumer and a pruned one for the share consumer.","Read the comma-separated key list in the error message - it tells you exactly which keys to drop."],"exampleFix":"// before\nprops.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, \"true\");\nprops.put(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG, ...);\nKafkaShareConsumer<String,String> c = new KafkaShareConsumer<>(props, deserializer, deserializer); // -> ConfigException\n\n// after\nprops.remove(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG);\nprops.remove(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG);\nKafkaShareConsumer<String,String> c = new KafkaShareConsumer<>(props, deserializer, deserializer);","handlingStrategy":"validation","validationCode":"Set<String> SHARE_UNSUPPORTED = Set.of(\n    ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,\n    ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG,\n    ConsumerConfig.GROUP_INSTANCE_ID_CONFIG,\n    ConsumerConfig.ISOLATION_LEVEL_CONFIG,\n    ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG,\n    ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG,\n    ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG,\n    ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG,\n    ConsumerConfig.GROUP_PROTOCOL_CONFIG,\n    ConsumerConfig.GROUP_REMOTE_ASSIGNOR_CONFIG);\nProperties shareProps = new Properties();\nclassicProps.stringPropertyNames().stream()\n    .filter(k -> !SHARE_UNSUPPORTED.contains(k))\n    .forEach(k -> shareProps.setProperty(k, classicProps.getProperty(k)));","typeGuard":"null","tryCatchPattern":"try { new KafkaShareConsumer<>(props, kd, vd); }\ncatch (ConfigException e) { /* strip listed keys from props, log, and fail fast */ throw e; }","preventionTips":["Maintain a separate, pruned properties file for share consumers.","Add a unit test asserting SHARE_GROUP_UNSUPPORTED_CONFIGS keys are absent before construction."],"tags":["share-consumer","config","validation","kafka-clients"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}