apache/kafka · error · InvalidConfigurationException

enable.auto.commit cannot be set to true when default group…

Error message

enable.auto.commit cannot be set to true when default group id (null) is used.

What it means

Thrown by ConsumerConfig.maybeOverrideEnableAutoCommit when group.id is null/empty (the default group id) but enable.auto.commit is explicitly set to true. Auto-commit only makes sense in the context of a group, so the consumer refuses to start in a contradictory state. Thrown as InvalidConfigurationException (a subclass of ConfigException).

Solutions

  1. If you need a group, set group.id to a non-empty value.
  2. If you don't use a group, set enable.auto.commit=false and commit manually (or use assign/seek patterns).
  3. Remove enable.auto.commit from the config so the client applies its own default when a group id is present.

Example fix

// before
props.put("enable.auto.commit", "true");
// no group.id set
new KafkaConsumer<>(props);

// after
props.put("group.id", "order-processor");
props.put("enable.auto.commit", "true");
new KafkaConsumer<>(props);
// OR, for standalone assignment:
props.put("enable.auto.commit", "false");
Defensive patterns

Strategy: validation

Validate before calling

String groupId = (String) configs.get(ConsumerConfig.GROUP_ID_CONFIG);
boolean autoCommit = Boolean.parseBoolean(String.valueOf(configs.get(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG)));
if ((groupId == null || groupId.isEmpty()) && autoCommit) {
    throw new ConfigException("enable.auto.commit=true requires a non-empty group.id");
}

Type guard

static boolean autoCommitConsistent(Map<String,Object> c) {
    String g = String.valueOf(c.get(ConsumerConfig.GROUP_ID_CONFIG));
    boolean ac = Boolean.parseBoolean(String.valueOf(c.get(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG)));
    return !(g.isEmpty() && ac);
}

Try / catch

try {
    consumer = new KafkaConsumer<>(props);
} catch (ConfigException e) {
    if (e.getMessage().contains("enable.auto.commit")) {
        props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
        consumer = new KafkaConsumer<>(props);
    } else throw e;
}

Prevention

When it happens

Trigger: Constructing a KafkaConsumer whose Properties omit group.id (or set it to empty) AND set enable.auto.commit=true. Common in standalone/assignment consumers that don't need a group but accidentally inherit auto-commit config.

Common situations: Using assign() patterns without a group id but copying a config template that has enable.auto.commit=true; transitioning from group consumption to standalone and forgetting to flip auto-commit off; defaulting group.id to empty in a multi-tenant loader.

Related errors


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

Appendix: source

Thrown at clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerConfig.java:814

            newConfigs.put(KEY_DESERIALIZER_CLASS_CONFIG, keyDeserializer.getClass());
        else if (newConfigs.get(KEY_DESERIALIZER_CLASS_CONFIG) == null)
            throw new ConfigException(KEY_DESERIALIZER_CLASS_CONFIG, null, "must be non-null.");
        if (valueDeserializer != null)
            newConfigs.put(VALUE_DESERIALIZER_CLASS_CONFIG, valueDeserializer.getClass());
        else if (newConfigs.get(VALUE_DESERIALIZER_CLASS_CONFIG) == null)
            throw new ConfigException(VALUE_DESERIALIZER_CLASS_CONFIG, null, "must be non-null.");
        return newConfigs;
    }

    private void maybeOverrideEnableAutoCommit(Map<String, Object> configs) {
        Optional<String> groupId = Optional.ofNullable(getString(CommonClientConfigs.GROUP_ID_CONFIG));
        Map<String, Object> originals = originals();
        boolean enableAutoCommit = originals.containsKey(ENABLE_AUTO_COMMIT_CONFIG) ? getBoolean(ENABLE_AUTO_COMMIT_CONFIG) : false;
        if (groupId.isEmpty()) { // overwrite in case of default group id where the config is not explicitly provided
            if (!originals.containsKey(ENABLE_AUTO_COMMIT_CONFIG)) {
                configs.put(ENABLE_AUTO_COMMIT_CONFIG, false);
            } else if (enableAutoCommit) {
                throw new InvalidConfigurationException(ENABLE_AUTO_COMMIT_CONFIG + " cannot be set to true when default group id (null) is used.");
            }
        }
    }

    protected void checkUnsupportedConfigsPostProcess() {
        String groupProtocol = getString(GROUP_PROTOCOL_CONFIG);
        if (GroupProtocol.CLASSIC.name().equalsIgnoreCase(groupProtocol)) {
            checkUnsupportedConfigsPostProcess(GroupProtocol.CLASSIC, CLASSIC_PROTOCOL_UNSUPPORTED_CONFIGS);
        } else if (GroupProtocol.CONSUMER.name().equalsIgnoreCase(groupProtocol)) {
            checkUnsupportedConfigsPostProcess(GroupProtocol.CONSUMER, CONSUMER_PROTOCOL_UNSUPPORTED_CONFIGS);
        }
    }

    private void checkUnsupportedConfigsPostProcess(GroupProtocol groupProtocol, List<String> unsupportedConfigs) {
        if (getString(GROUP_PROTOCOL_CONFIG).equalsIgnoreCase(groupProtocol.name())) {
            List<String> invalidConfigs = new ArrayList<>();
            unsupportedConfigs.forEach(configName -> {
                Object config = originals().get(configName);

View on GitHub (pinned to 996fb4585a)