{"record":{"id":"68ec541077ea4248","repo":"apache/flink","slug":"the-binary-operation-has-no-second-input","errorCode":null,"errorMessage":"The binary operation {} has no second input.","messagePattern":"The binary operation (.+?) has no second input\\.","errorType":"validation","errorClass":"InvalidProgramException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/operators/CollectionExecutor.java","lineNumber":287,"sourceCode":"        } else {\n            ctx = null;\n        }\n\n        return typedOp.executeOnCollections(inputData, ctx, executionConfig);\n    }\n\n    private <IN1, IN2, OUT> List<OUT> executeBinaryOperator(\n            DualInputOperator<?, ?, ?, ?> operator, int superStep, JobInfo jobInfo)\n            throws Exception {\n        Operator<?> inputOp1 = operator.getFirstInput();\n        Operator<?> inputOp2 = operator.getSecondInput();\n\n        if (inputOp1 == null) {\n            throw new InvalidProgramException(\n                    \"The binary operation \" + operator.getName() + \" has no first input.\");\n        }\n        if (inputOp2 == null) {\n            throw new InvalidProgramException(\n                    \"The binary operation \" + operator.getName() + \" has no second input.\");\n        }\n\n        // compute inputs\n        @SuppressWarnings(\"unchecked\")\n        List<IN1> inputData1 = (List<IN1>) execute(inputOp1, superStep, jobInfo);\n        @SuppressWarnings(\"unchecked\")\n        List<IN2> inputData2 = (List<IN2>) execute(inputOp2, superStep, jobInfo);\n\n        @SuppressWarnings(\"unchecked\")\n        DualInputOperator<IN1, IN2, OUT, ?> typedOp =\n                (DualInputOperator<IN1, IN2, 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())) {","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/operators/CollectionExecutor.java#L269-L305","documentation":"Thrown by CollectionExecutor.executeBinaryOperator() when operator.getSecondInput() returns null for a DualInputOperator (e.g., JoinOperator, CoGroupOperator). This is the symmetric counterpart of error 367: the right (second) input is null. A binary operator needs both inputs to produce results.","triggerScenarios":"A DualInputOperator is created where the right input DataSet is null. In the high-level API, the DataSet on the right side of a .join()/.cogroup()/.cross() call is null. For example, leftInput.join(nullRhs) or the right DataSet variable was never assigned.","commonSituations":"The right-side DataSet of a join/cogroup/cross is null because the transformation producing it was skipped, returned null, or the variable was conditionally assigned. Frequently seen when join inputs come from different source reads and one source fails to initialize.","solutions":["Verify the right input DataSet is non-null before the join/cogroup/cross call.","Print the plan or check both input variables in a debugger to identify which side is null.","Ensure both source readers (readTextFile, fromCollection, etc.) return non-null DataSets."],"exampleFix":"// before — rightInput is null\nDataSet<Tuple2> rightInput = null;\nleftInput.join(rightInput).where(0).equalTo(0);\n// after\nDataSet<Tuple2> rightInput = env.fromElements(Tuple2.of(1, \"x\"));\nleftInput.join(rightInput).where(0).equalTo(0);","handlingStrategy":"validation","validationCode":"// Verify right input is non-null before join/cogroup/cross\nif (rightInput == null) {\n    throw new IllegalStateException(\"Right input for join is null\");\n}\nleftInput.join(rightInput).where(0).equalTo(0);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate both join inputs are non-null — check the right side specifically.","Ensure source readers producing join inputs return non-null DataSets.","Print the plan to verify the second input of each DualInputOperator is connected."],"tags":["binary-operator","join","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"}