apache/flink · error · IllegalArgumentException

The minimum split size cannot be negative.

Error message

The minimum split size cannot be negative.

What it means

minSplitSize is a lower bound on input split size used by the split assignment logic. A negative value has no physical meaning (splits cannot have negative size), so FileInputFormat.setMinSplitSize rejects it with IllegalArgumentException. Zero and positive values are accepted.

Source

Thrown at flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java:322

    /**
     * Sets multiple paths of files to be read.
     *
     * @param filePaths The paths of the files to read.
     */
    public void setFilePaths(Path... filePaths) {
        if (filePaths.length < 1) {
            throw new IllegalArgumentException("At least one file path must be specified.");
        }
        this.filePaths = filePaths;
    }

    public long getMinSplitSize() {
        return minSplitSize;
    }

    public void setMinSplitSize(long minSplitSize) {
        if (minSplitSize < 0) {
            throw new IllegalArgumentException("The minimum split size cannot be negative.");
        }

        this.minSplitSize = minSplitSize;
    }

    public int getNumSplits() {
        return numSplits;
    }

    public void setNumSplits(int numSplits) {
        if (numSplits < -1 || numSplits == 0) {
            throw new IllegalArgumentException(
                    "The desired number of splits must be positive or -1 (= don't care).");
        }

        this.numSplits = numSplits;
    }

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Pass a non-negative value, e.g. format.setMinSplitSize(0) to impose no minimum or a positive byte count.
  2. Do not call setMinSplitSize if you want the default behavior.
  3. Validate the computed value is >= 0 before calling.

Example fix

// before
format.setMinSplitSize(minBytes); // minBytes == -1 -> throws

// after
long min = minBytes >= 0 ? minBytes : 0;
format.setMinSplitSize(min);
Defensive patterns

Strategy: validation

Validate before calling

long min = minSplitSize >= 0 ? minSplitSize : 0;
format.setMinSplitSize(min);

Prevention

When it happens

Trigger: Calling format.setMinSplitSize(-1) or any negative long.

Common situations: Computing min split size from a subtraction that underflows; passing -1 intending 'use default' (the format has no such sentinel — leave the setter uncalled instead); misconfiguring from a property that defaulted to -1.

Related errors


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