apache/flink · error · IllegalArgumentException
The 'to' value must not be smaller than the 'from' value.
Error message
The 'to' value must not be smaller than the 'from' value.
What it means
LongValueSequenceIterator generates the inclusive range [from, to] of longs. The constructor enforces from <= to and throws IllegalArgumentException otherwise, because an empty/reversed range is not representable by this iterator (an internal constructor exists for empty iterators).
Source
Thrown at flink-core/src/main/java/org/apache/flink/util/LongValueSequenceIterator.java:54
/** The last number returned by the iterator. */
private final long to;
/** The next number to be returned. */
private long current;
/** The next value to be returned. */
private LongValue currentValue = new LongValue();
/**
* Creates a new splittable iterator, returning the range [from, to]. Both boundaries of the
* interval are inclusive.
*
* @param from The first number returned by the iterator.
* @param to The last number returned by the iterator.
*/
public LongValueSequenceIterator(long from, long to) {
if (from > to) {
throw new IllegalArgumentException(
"The 'to' value must not be smaller than the 'from' value.");
}
this.current = from;
this.to = to;
}
/**
* Internal constructor to allow for empty iterators.
*
* @param from The first number returned by the iterator.
* @param to The last number returned by the iterator.
* @param unused A dummy parameter to disambiguate the constructor.
*/
private LongValueSequenceIterator(long from, long to, boolean unused) {
this.current = from;
this.to = to;
}View on GitHub (pinned to 2f3c205e92)
Solutions
- Check and correct the range parameters: ensure from <= to before constructing (swap or clamp as your semantics require).
- Validate user-supplied range configs at parse time with a clear error message naming both values.
- If an empty range is legitimate in your flow, skip iterator creation when from > to instead of constructing it.
- Add boundary unit tests for from == to (single element) and from == to + 1 to catch regressions.
Example fix
// before
new LongValueSequenceIterator(start, end); // start=10, end=5 -> IAE
// after
if (start > end) {
throw new IllegalArgumentException("start (" + start + ") must be <= end (" + end + ")");
}
return new LongValueSequenceIterator(start, end); Defensive patterns
Strategy: validation
Validate before calling
if (from > to) {
throw new IllegalArgumentException("from (" + from + ") must be <= to (" + to + ")");
}
return new LongValueSequenceIterator(from, to); Prevention
- Validate range bounds at config-parse time
- Skip iterator construction for empty ranges
- Unit-test from == to and from == to + 1 boundaries
When it happens
Trigger: Constructing new LongValueSequenceIterator(from, to) with from > to — e.g. computing bounds from dynamic input where the start overtook the end, or off-by-one math producing start = end + 1.
Common situations: Generating test/benchmark data ranges from configuration values (e.g. datagen-style sequence sources) where the user sets 'from' greater than 'to'; range arithmetic where the upper bound minus count undershoots the lower bound.
Related errors
- The number of partitions must be at least 1.
- The 'to' value must not be smaller than the 'from' value.
- The number of partitions must be at least 1.
- {e.getMessage()}
- Cannot access jar file{t.getMessage() == null ? "." : ": " +
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/67dacb1213e9ac3e.
Report an issue: GitHub.