{"record":{"id":"d47486a01bc9bf73","repo":"apache/flink","slug":"the-unary-operation-has-no-input","errorCode":null,"errorMessage":"The unary operation {} has no input.","messagePattern":"The unary operation (.+?) has no input\\.","errorType":"validation","errorClass":"InvalidProgramException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/operators/CollectionExecutor.java","lineNumber":247,"sourceCode":"        TaskInfo taskInfo = new TaskInfoImpl(typedSource.getName(), 1, 0, 1, 0);\n\n        RuntimeUDFContext ctx;\n\n        if (RichInputFormat.class.isAssignableFrom(\n                typedSource.getUserCodeWrapper().getUserCodeClass())) {\n            ctx = createContext(superStep, taskInfo, jobInfo);\n        } else {\n            ctx = null;\n        }\n        return typedSource.executeOnCollections(ctx, executionConfig);\n    }\n\n    private <IN, OUT> List<OUT> executeUnaryOperator(\n            SingleInputOperator<?, ?, ?> operator, int superStep, JobInfo jobInfo)\n            throws Exception {\n        Operator<?> inputOp = operator.getInput();\n        if (inputOp == null) {\n            throw new InvalidProgramException(\n                    \"The unary operation \" + operator.getName() + \" has no input.\");\n        }\n\n        @SuppressWarnings(\"unchecked\")\n        List<IN> inputData = (List<IN>) execute(inputOp, superStep, jobInfo);\n\n        @SuppressWarnings(\"unchecked\")\n        SingleInputOperator<IN, OUT, ?> typedOp = (SingleInputOperator<IN, OUT, ?>) operator;\n\n        // build the runtime context and compute broadcast variables, if necessary\n        TaskInfo taskInfo = new TaskInfoImpl(typedOp.getName(), 1, 0, 1, 0);\n        RuntimeUDFContext ctx;\n\n        if (RichFunction.class.isAssignableFrom(typedOp.getUserCodeWrapper().getUserCodeClass())) {\n            ctx = createContext(superStep, taskInfo, jobInfo);\n\n            for (Map.Entry<String, Operator<?>> bcInputs :\n                    operator.getBroadcastInputs().entrySet()) {","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/operators/CollectionExecutor.java#L229-L265","documentation":"Thrown by CollectionExecutor.executeUnaryOperator() when operator.getInput() returns null for a SingleInputOperator (e.g., MapOperator, FilterOperator, ReduceOperator). Every unary operator must have exactly one input; a null input means the operator was never connected to a preceding data source. This is an InvalidProgramException signaling a broken plan chain.","triggerScenarios":"A SingleInputOperator (map, flatMap, filter, reduce, etc.) is created without an input. In the high-level API, this happens if the input DataSet passed to .map()/.filter() is null, or if the operator was constructed programmatically and setInput() was never called.","commonSituations":"A variable holding the input DataSet is null due to an earlier transformation error or a logic bug (e.g., assigning in an if-branch that was not taken). Also seen in unit tests that build operators manually without wiring inputs.","solutions":["Trace the input DataSet variable to find where it became null — check the transformation chain that should produce it.","Use env.createPlanAsJSON() or print the execution plan to verify all operators have inputs.","Ensure the source operator (env.fromElements, env.readTextFile, etc.) is non-null and properly chained to the unary operator."],"exampleFix":"// before — input dataSet is null\nDataSet<String> result = null;\nresult.map(x -> x.toUpperCase()).writeAsText(path);\n// after\nDataSet<String> source = env.fromElements(\"a\", \"b\");\nDataSet<String> result = source.map(x -> x.toUpperCase());\nresult.writeAsText(path);","handlingStrategy":"validation","validationCode":"// Verify input DataSet is non-null before transformations\nif (inputDataSet == null) {\n    throw new IllegalStateException(\"Input DataSet for map/filter/reduce is null\");\n}\ninputDataSet.map(fn);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify every DataSet variable is non-null before calling .map()/.filter()/.reduce() on it.","Trace transformation chains back to the source to ensure no broken links.","Use env.createPlanAsJSON() to inspect the plan and detect unconnected operators."],"tags":["unary-operator","plan-validation","collection-executor","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}