apache/flink · error · RuntimeException

Operator for initial partial solution is not set.

Error message

Operator for initial partial solution is not set.

What it means

Thrown by BulkIterationBase.validate() as a RuntimeException when the input operator (the initial partial solution / source data for the iteration) is null. The iteration has no data to iterate over, which is a fundamental construction error.

Source

Thrown at flink-core/src/main/java/org/apache/flink/api/common/operators/base/BulkIterationBase.java:168

        }
        this.numberOfIterations = num;
    }

    public int getMaximumNumberOfIterations() {
        return this.numberOfIterations;
    }

    @Override
    public AggregatorRegistry getAggregators() {
        return this.aggregators;
    }

    /**
     * @throws InvalidProgramException
     */
    public void validate() throws InvalidProgramException {
        if (this.input == null) {
            throw new RuntimeException("Operator for initial partial solution is not set.");
        }
        if (this.iterationResult == null) {
            throw new InvalidProgramException(
                    "Operator producing the next version of the partial "
                            + "solution (iteration result) is not set.");
        }
        if (this.terminationCriterion == null && this.numberOfIterations <= 0) {
            throw new InvalidProgramException(
                    "No termination condition is set "
                            + "(neither fix number of iteration nor termination criterion).");
        }
    }

    /**
     * The BulkIteration meta operator cannot have broadcast inputs.
     *
     * @return An empty map.
     */

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Always call iteration.setInput(initialDataOperator) before validate() or execute().
  2. Ensure the input chain (the data source feeding the iteration) is fully connected before triggering validation.
  3. Check that the source data operator is non-null and wired into the iteration's first input.

Example fix

// before
BulkIterationBase<MyType> iteration = new BulkIterationBase<>(operatorInfo, "my-iter");
iteration.setNextPartialSolution(stepFunction);
iteration.setMaximumNumberOfIterations(10);
iteration.validate(); // throws: input not set

// after
BulkIterationBase<MyType> iteration = new BulkIterationBase<>(operatorInfo, "my-iter");
iteration.setInput(dataSource); // connect initial data
iteration.setNextPartialSolution(stepFunction);
iteration.setMaximumNumberOfIterations(10);
iteration.validate(); // ok
Defensive patterns

Strategy: validation

Validate before calling

void validateBeforeExecute(BulkIterationBase<?> iter) {
    if (iter.getInput() == null) {
        throw new IllegalStateException("Iteration input (initial partial solution) is not set.");
    }
    iter.validate();
}

Type guard

boolean hasInput(BulkIterationBase<?> iter) {
    return iter.getInput() != null;
}

Try / catch

try {
    iteration.validate();
} catch (RuntimeException e) {
    if (e.getMessage().contains("initial partial solution")) {
        // connect the input data source
        iteration.setInput(dataSource);
        iteration.validate();
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Creating a BulkIterationBase and calling validate() (or executing the plan which triggers validate()) without calling setInput() or otherwise providing the initial data source. The input field is inherited from SingleInputOperator and must be set.

Common situations: Building a bulk iteration but forgetting to connect the input data source. Refactoring that removes or nulls the input operator. Using an iteration where the input was supposed to come from a prior transformation that failed to connect.

Related errors


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