{"record":{"id":"c6b24eaa44833347","repo":"apache/flink","slug":"operator-producing-the-next-version-of-the-partial","errorCode":null,"errorMessage":"Operator producing the next version of the partial solution (iteration result) is not set.","messagePattern":"Operator producing the next version of the partial solution \\(iteration result\\) is not set\\.","errorType":"exception","errorClass":"InvalidProgramException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/operators/base/BulkIterationBase.java","lineNumber":171,"sourceCode":"\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     */\n    public Map<String, Operator<?>> getBroadcastInputs() {\n        return Collections.emptyMap();\n    }","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/operators/base/BulkIterationBase.java#L153-L189","documentation":"Thrown by BulkIterationBase.validate() as an InvalidProgramException when iterationResult is null — meaning setNextPartialSolution() was never called. The iteration body (the step function that produces the next version of the partial solution) is mandatory; without it the iteration has no way to progress.","triggerScenarios":"Creating a BulkIterationBase, setting the input and iteration count, but forgetting to call setNextPartialSolution(stepFunction). Calling validate() before the step function is defined.","commonSituations":"Incomplete iteration construction in programmatic DataSet API usage. Conditional code paths that set the step function only in some branches. Refactoring that removes the setNextPartialSolution call without updating the validate flow.","solutions":["Always call iteration.setNextPartialSolution(stepFunctionOperator) before validate() or execute().","Ensure the step function operator (built from iteration.getPartialSolution()) is non-null and properly connected.","Structure iteration construction to guarantee the step function is set in all code paths."],"exampleFix":"// before\nBulkIterationBase<MyType> iteration = new BulkIterationBase<>(operatorInfo, \"my-iter\");\niteration.setInput(dataSource);\niteration.setMaximumNumberOfIterations(10);\niteration.validate(); // throws: iterationResult not set\n\n// after\nBulkIterationBase<MyType> iteration = new BulkIterationBase<>(operatorInfo, \"my-iter\");\niteration.setInput(dataSource);\nOperator<MyType> step = buildStep(iteration.getPartialSolution());\niteration.setNextPartialSolution(step);\niteration.setMaximumNumberOfIterations(10);\niteration.validate(); // ok","handlingStrategy":"validation","validationCode":"void validateBeforeExecute(BulkIterationBase<?> iter) {\n    if (iter.getNextPartialSolution() == null) {\n        throw new IllegalStateException(\"Iteration step function (next partial solution) is not set.\");\n    }\n    iter.validate();\n}","typeGuard":"boolean hasStepFunction(BulkIterationBase<?> iter) {\n    return iter.getNextPartialSolution() != null;\n}","tryCatchPattern":"try {\n    iteration.validate();\n} catch (InvalidProgramException e) {\n    if (e.getMessage().contains(\"iteration result\")) {\n        // build and set the step function\n        Operator<?> step = buildStepFunction(iteration.getPartialSolution());\n        iteration.setNextPartialSolution(step);\n        iteration.validate();\n    } else {\n        throw e;\n    }\n}","preventionTips":["Build the step function from iteration.getPartialSolution() and call setNextPartialSolution before validate.","Structure code so the step function construction is unconditional.","Call validate() early in development."],"tags":["bulk-iteration","validation","missing-step-function","invalid-program","dataset-api","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}