apache/flink · error · IllegalArgumentException

The input may not contain null elements.

Error message

The input may not contain null elements.

What it means

Thrown by Operator.createUnionCascade when input2[0] is null at the point of setting the first input of the union cascade. Even though type may have been inferred earlier, the method explicitly rejects null operators before wiring them into the Union DAG.

Source

Thrown at flink-core/src/main/java/org/apache/flink/api/common/operators/Operator.java:261

            return input2[0];
        }

        TypeInformation<T> type = null;
        if (input1 != null) {
            type = input1.getOperatorInfo().getOutputType();
        } else if (input2.length > 0 && input2[0] != null) {
            type = input2[0].getOperatorInfo().getOutputType();
        } else {
            throw new IllegalArgumentException("Could not determine type information from inputs.");
        }

        // Otherwise construct union cascade
        Union<T> lastUnion =
                new Union<T>(new BinaryOperatorInformation<T, T, T>(type, type, type), "<unknown>");

        int i;
        if (input2[0] == null) {
            throw new IllegalArgumentException("The input may not contain null elements.");
        }
        lastUnion.setFirstInput(input2[0]);

        if (input1 != null) {
            lastUnion.setSecondInput(input1);
            i = 1;
        } else {
            if (input2[1] == null) {
                throw new IllegalArgumentException("The input may not contain null elements.");
            }
            lastUnion.setSecondInput(input2[1]);
            i = 2;
        }
        for (; i < input2.length; i++) {
            Union<T> tmpUnion =
                    new Union<T>(
                            new BinaryOperatorInformation<T, T, T>(type, type, type), "<unknown>");
            tmpUnion.setSecondInput(lastUnion);

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Remove null elements from the operators array before calling createUnionCascade.
  2. Ensure the first vararg element is always a concrete operator.
  3. Use a filtered/validated list builder.

Example fix

// before
Operator.createUnionCascade(first, new Operator[]{null, second});

// after
Operator.createUnionCascade(first, new Operator[]{second});  // null removed
Defensive patterns

Strategy: validation

Validate before calling

if (input2 != null && input2.length > 0 && input2[0] == null) {
    throw new IllegalArgumentException("input2[0] must not be null.");
}

Prevention

When it happens

Trigger: createUnionCascade(input1, null, otherOp) where the first element of the varargs array is null. Passing a list whose first entry is a null operator.

Common situations: Varargs arrays built from nullable sources where the first slot is null. Refactors that reorder operators leaving null at index 0.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/925fd1c2554fa7cc. Report an issue: GitHub.