{"record":{"id":"037eb728dfe33223","repo":"apache/flink","slug":"the-iteration-has-no-workset-defined-is-not-cl","errorCode":null,"errorMessage":"The iteration {} has no workset defined (is not closed).","messagePattern":"The iteration (.+?) has no workset defined \\(is not closed\\)\\.","errorType":"validation","errorClass":"InvalidProgramException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/operators/CollectionExecutor.java","lineNumber":424,"sourceCode":"            throws Exception {\n        Operator<?> solutionInput = iteration.getInitialSolutionSet();\n        Operator<?> worksetInput = iteration.getInitialWorkset();\n        if (solutionInput == null) {\n            throw new InvalidProgramException(\n                    \"The delta iteration \" + iteration.getName() + \" has no initial solution set.\");\n        }\n        if (worksetInput == null) {\n            throw new InvalidProgramException(\n                    \"The delta iteration \" + iteration.getName() + \" has no initial workset.\");\n        }\n        if (iteration.getSolutionSetDelta() == null) {\n            throw new InvalidProgramException(\n                    \"The iteration \"\n                            + iteration.getName()\n                            + \" has no solution set delta defined (is not closed).\");\n        }\n        if (iteration.getNextWorkset() == null) {\n            throw new InvalidProgramException(\n                    \"The iteration \"\n                            + iteration.getName()\n                            + \" has no workset defined (is not closed).\");\n        }\n\n        List<T> solutionInputData = (List<T>) execute(solutionInput, jobInfo);\n        List<T> worksetInputData = (List<T>) execute(worksetInput, jobInfo);\n\n        // get the operators that are iterative\n        Set<Operator<?>> dynamics = new LinkedHashSet<Operator<?>>();\n        DynamicPathCollector dynCollector = new DynamicPathCollector(dynamics);\n        iteration.getSolutionSetDelta().accept(dynCollector);\n        iteration.getNextWorkset().accept(dynCollector);\n\n        BinaryOperatorInformation<?, ?, ?> operatorInfo = iteration.getOperatorInfo();\n        TypeInformation<?> solutionType = operatorInfo.getFirstInputType();\n\n        int[] keyColumns = iteration.getSolutionSetKeyFields();","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/operators/CollectionExecutor.java#L406-L442","documentation":"Thrown by CollectionExecutor.executeDeltaIteration() when iteration.getNextWorkset() returns null. The next workset defines what data the next iteration step will process; a null value means the delta iteration was not fully closed — closeWith() was either not called or was called without a next workset argument. This is an InvalidProgramException.","triggerScenarios":"A delta iteration is created but closeWith() was not called with the second argument (nextWorkset), or closeWith() was not called at all. The solution set delta may be set (error 373 would not trigger) but the next workset is missing, indicating an incomplete closeWith() call.","commonSituations":"A developer calls closeWith(delta) (single-argument form) instead of closeWith(delta, nextWorkset) (two-argument form) for a delta iteration. The single-argument closeWith is valid for bulk iterations but insufficient for delta iterations which need both the delta and the next workset.","solutions":["Use the two-argument closeWith(solutionSetDelta, nextWorkset) form for delta iterations.","Verify that nextWorkset is a non-null DataSet produced by the step function.","Review the delta iteration close pattern: closeWith(delta, nextWorkset) requires both arguments."],"exampleFix":"// before — only one argument to closeWith\nDataSet<S> result = iter.closeWith(delta);\n// after — both delta and nextWorkset required\nDataSet<W> nextWorkset = stepResult.project(0);\nDataSet<S> result = iter.closeWith(delta, nextWorkset);","handlingStrategy":"validation","validationCode":"// Ensure delta iteration has a next workset in closeWith\nDeltaIteration<S,W> iter = solutionSet.iterateDelta(workset, 100, 0);\nDataSet<S> delta = computeDelta(iter);\nDataSet<W> nextWorkset = computeNextWorkset(iter);\nif (nextWorkset == null) {\n    throw new IllegalStateException(\"Next workset for delta iteration is null\");\n}\nDataSet<S> result = iter.closeWith(delta, nextWorkset);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the two-argument closeWith(delta, nextWorkset) form, never the single-argument form for delta iterations.","Verify nextWorkset is a non-null DataSet produced by the step body.","Static analysis: grep for iterateDelta( followed by closeWith( with only one argument."],"tags":["iteration","delta-iteration","plan-validation","closewith","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}