apache/flink · error · IllegalArgumentException

Name and aggregator must not be null

Error message

Name and aggregator must not be null

What it means

Thrown by AggregatorRegistry.registerAggregator when either the name or the aggregator is null. Iterative Flink programs (bulk/delta iteration) use named Aggregators to aggregate per-superstep values; both a non-null name (to identify the aggregator) and a non-null aggregator instance are required. Null for either would break iteration aggregation.

Source

Thrown at flink-core/src/main/java/org/apache/flink/api/common/aggregators/AggregatorRegistry.java:43

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/** A registry for iteration {@link Aggregator}s. */
@Internal
public class AggregatorRegistry {

    private final Map<String, Aggregator<?>> registry = new HashMap<String, Aggregator<?>>();

    private ConvergenceCriterion<? extends Value> convergenceCriterion;

    private String convergenceCriterionAggregatorName;

    // --------------------------------------------------------------------------------------------

    public void registerAggregator(String name, Aggregator<?> aggregator) {
        if (name == null || aggregator == null) {
            throw new IllegalArgumentException("Name and aggregator must not be null");
        }
        if (this.registry.containsKey(name)) {
            throw new RuntimeException("An aggregator is already registered under the given name.");
        }
        this.registry.put(name, aggregator);
    }

    public Collection<AggregatorWithName<?>> getAllRegisteredAggregators() {
        ArrayList<AggregatorWithName<?>> list =
                new ArrayList<AggregatorWithName<?>>(this.registry.size());

        for (Map.Entry<String, Aggregator<?>> entry : this.registry.entrySet()) {
            @SuppressWarnings("unchecked")
            Aggregator<Value> valAgg = (Aggregator<Value>) entry.getValue();
            list.add(new AggregatorWithName<>(entry.getKey(), valAgg));
        }
        return list;
    }

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Ensure both name and aggregator are non-null before calling registerAggregator; validate the source of the name string.
  2. If loading the aggregator class dynamically, instantiate and null-check before registration.
  3. Prefer the iteration API helpers that build aggregator registration from validated inputs.

Example fix

// before
registry.registerAggregator(maybeNullName, maybeNullAgg);
// after
Objects.requireNonNull(name, "aggregator name");
Objects.requireNonNull(aggregator, "aggregator");
registry.registerAggregator(name, aggregator);
Defensive patterns

Strategy: validation

Validate before calling

Objects.requireNonNull(name, "name");
Objects.requireNonNull(aggregator, "aggregator");
registry.registerAggregator(name, aggregator);

Prevention

When it happens

Trigger: Calling registerAggregator(null, agg) or registerAggregator(name, null); building aggregator names from config that yielded null; reflection-created aggregator that failed to instantiate.

Common situations: Custom iterative jobs registering convergence aggregators; tests wiring AggregatorRegistry by hand; aggregator class loaded from a config key that wasn't set.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/678fb54c8af529dd. Report an issue: GitHub.