{"record":{"id":"ebce603e299e4484","repo":"apache/flink","slug":"operator-for-initial-partial-solution-is-not-set","errorCode":null,"errorMessage":"Operator for initial partial solution is not set.","messagePattern":"Operator for initial partial solution is not set\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/operators/base/BulkIterationBase.java","lineNumber":168,"sourceCode":"        }\n        this.numberOfIterations = num;\n    }\n\n    public int getMaximumNumberOfIterations() {\n        return this.numberOfIterations;\n    }\n\n    @Override\n    public AggregatorRegistry getAggregators() {\n        return this.aggregators;\n    }\n\n    /**\n     * @throws InvalidProgramException\n     */\n    public void validate() throws InvalidProgramException {\n        if (this.input == null) {\n            throw new RuntimeException(\"Operator for initial partial solution is not set.\");\n        }\n        if (this.iterationResult == null) {\n            throw new InvalidProgramException(\n                    \"Operator producing the next version of the partial \"\n                            + \"solution (iteration result) is not set.\");\n        }\n        if (this.terminationCriterion == null && this.numberOfIterations <= 0) {\n            throw new InvalidProgramException(\n                    \"No termination condition is set \"\n                            + \"(neither fix number of iteration nor termination criterion).\");\n        }\n    }\n\n    /**\n     * The BulkIteration meta operator cannot have broadcast inputs.\n     *\n     * @return An empty map.\n     */","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/operators/base/BulkIterationBase.java#L150-L186","documentation":"Thrown by BulkIterationBase.validate() as a RuntimeException when the input operator (the initial partial solution / source data for the iteration) is null. The iteration has no data to iterate over, which is a fundamental construction error.","triggerScenarios":"Creating a BulkIterationBase and calling validate() (or executing the plan which triggers validate()) without calling setInput() or otherwise providing the initial data source. The input field is inherited from SingleInputOperator and must be set.","commonSituations":"Building a bulk iteration but forgetting to connect the input data source. Refactoring that removes or nulls the input operator. Using an iteration where the input was supposed to come from a prior transformation that failed to connect.","solutions":["Always call iteration.setInput(initialDataOperator) before validate() or execute().","Ensure the input chain (the data source feeding the iteration) is fully connected before triggering validation.","Check that the source data operator is non-null and wired into the iteration's first input."],"exampleFix":"// before\nBulkIterationBase<MyType> iteration = new BulkIterationBase<>(operatorInfo, \"my-iter\");\niteration.setNextPartialSolution(stepFunction);\niteration.setMaximumNumberOfIterations(10);\niteration.validate(); // throws: input not set\n\n// after\nBulkIterationBase<MyType> iteration = new BulkIterationBase<>(operatorInfo, \"my-iter\");\niteration.setInput(dataSource); // connect initial data\niteration.setNextPartialSolution(stepFunction);\niteration.setMaximumNumberOfIterations(10);\niteration.validate(); // ok","handlingStrategy":"validation","validationCode":"void validateBeforeExecute(BulkIterationBase<?> iter) {\n    if (iter.getInput() == null) {\n        throw new IllegalStateException(\"Iteration input (initial partial solution) is not set.\");\n    }\n    iter.validate();\n}","typeGuard":"boolean hasInput(BulkIterationBase<?> iter) {\n    return iter.getInput() != null;\n}","tryCatchPattern":"try {\n    iteration.validate();\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"initial partial solution\")) {\n        // connect the input data source\n        iteration.setInput(dataSource);\n        iteration.validate();\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always call iteration.setInput(dataSource) right after creating the iteration.","Call validate() during development to catch missing inputs early.","Use a builder pattern or factory that guarantees the input is connected."],"tags":["bulk-iteration","validation","missing-input","dataset-api","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}