{"record":{"id":"678fb54c8af529dd","repo":"apache/flink","slug":"name-and-aggregator-must-not-be-null","errorCode":null,"errorMessage":"Name and aggregator must not be null","messagePattern":"Name and aggregator must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/aggregators/AggregatorRegistry.java","lineNumber":43,"sourceCode":"import java.util.Collection;\nimport java.util.HashMap;\nimport java.util.Map;\n\n/** A registry for iteration {@link Aggregator}s. */\n@Internal\npublic class AggregatorRegistry {\n\n    private final Map<String, Aggregator<?>> registry = new HashMap<String, Aggregator<?>>();\n\n    private ConvergenceCriterion<? extends Value> convergenceCriterion;\n\n    private String convergenceCriterionAggregatorName;\n\n    // --------------------------------------------------------------------------------------------\n\n    public void registerAggregator(String name, Aggregator<?> aggregator) {\n        if (name == null || aggregator == null) {\n            throw new IllegalArgumentException(\"Name and aggregator must not be null\");\n        }\n        if (this.registry.containsKey(name)) {\n            throw new RuntimeException(\"An aggregator is already registered under the given name.\");\n        }\n        this.registry.put(name, aggregator);\n    }\n\n    public Collection<AggregatorWithName<?>> getAllRegisteredAggregators() {\n        ArrayList<AggregatorWithName<?>> list =\n                new ArrayList<AggregatorWithName<?>>(this.registry.size());\n\n        for (Map.Entry<String, Aggregator<?>> entry : this.registry.entrySet()) {\n            @SuppressWarnings(\"unchecked\")\n            Aggregator<Value> valAgg = (Aggregator<Value>) entry.getValue();\n            list.add(new AggregatorWithName<>(entry.getKey(), valAgg));\n        }\n        return list;\n    }","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/aggregators/AggregatorRegistry.java#L25-L61","documentation":"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.","triggerScenarios":"Calling registerAggregator(null, agg) or registerAggregator(name, null); building aggregator names from config that yielded null; reflection-created aggregator that failed to instantiate.","commonSituations":"Custom iterative jobs registering convergence aggregators; tests wiring AggregatorRegistry by hand; aggregator class loaded from a config key that wasn't set.","solutions":["Ensure both name and aggregator are non-null before calling registerAggregator; validate the source of the name string.","If loading the aggregator class dynamically, instantiate and null-check before registration.","Prefer the iteration API helpers that build aggregator registration from validated inputs."],"exampleFix":"// before\nregistry.registerAggregator(maybeNullName, maybeNullAgg);\n// after\nObjects.requireNonNull(name, \"aggregator name\");\nObjects.requireNonNull(aggregator, \"aggregator\");\nregistry.registerAggregator(name, aggregator);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(name, \"name\");\nObjects.requireNonNull(aggregator, \"aggregator\");\nregistry.registerAggregator(name, aggregator);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate name and aggregator at the source before registration.","Centralize aggregator construction in one factory.","Reject null config-derived names early."],"tags":["aggregator","iteration","null-check","registration"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}