apache/kafka · error · ConfigException

cannot be set when using a share group.

Error message

{} cannot be set when using a share group.

What it means

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.

Solutions

  1. 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).
  2. 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.
  3. Read the comma-separated key list in the error message - it tells you exactly which keys to drop.

Example fix

// before
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true");
props.put(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG, ...);
KafkaShareConsumer<String,String> c = new KafkaShareConsumer<>(props, deserializer, deserializer); // -> ConfigException

// after
props.remove(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG);
props.remove(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG);
KafkaShareConsumer<String,String> c = new KafkaShareConsumer<>(props, deserializer, deserializer);
Defensive patterns

Strategy: validation

Validate before calling

Set<String> SHARE_UNSUPPORTED = Set.of(
    ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,
    ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG,
    ConsumerConfig.GROUP_INSTANCE_ID_CONFIG,
    ConsumerConfig.ISOLATION_LEVEL_CONFIG,
    ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG,
    ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG,
    ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG,
    ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG,
    ConsumerConfig.GROUP_PROTOCOL_CONFIG,
    ConsumerConfig.GROUP_REMOTE_ASSIGNOR_CONFIG);
Properties shareProps = new Properties();
classicProps.stringPropertyNames().stream()
    .filter(k -> !SHARE_UNSUPPORTED.contains(k))
    .forEach(k -> shareProps.setProperty(k, classicProps.getProperty(k)));

Type guard

null

Try / catch

try { new KafkaShareConsumer<>(props, kd, vd); }
catch (ConfigException e) { /* strip listed keys from props, log, and fail fast */ throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/kafka@996fb4585a (2026-08-11). Data as JSON: /api/errors/6a94b568c0e6b180. Report an issue: GitHub.

Appendix: source

Thrown at clients/src/main/java/org/apache/kafka/clients/consumer/ShareConsumerConfig.java:72

    protected ShareConsumerConfig(Map<?, ?> props, boolean doLog) {
        super(props, doLog);
    }

    @Override
    protected Map<String, Object> preProcessParsedConfig(final Map<String, Object> parsedValues) {
        checkUnsupportedConfigsPreProcess(parsedValues);
        return parsedValues;
    }

    private void checkUnsupportedConfigsPreProcess(Map<String, Object> parsedValues) {
        List<String> invalidConfigs = new ArrayList<>();
        SHARE_GROUP_UNSUPPORTED_CONFIGS.forEach(configName -> {
            if (parsedValues.containsKey(configName)) {
                invalidConfigs.add(configName);
            }
        });
        if (!invalidConfigs.isEmpty()) {
            throw new ConfigException(String.join(", ", invalidConfigs) +
                    " cannot be set when using a share group.");
        }
    }

    @Override
    protected void checkUnsupportedConfigsPostProcess() {
    }
}

View on GitHub (pinned to 996fb4585a)