apache/beam · error · IllegalArgumentException
Minimum ( ) must not be greater than maximum ( )
Error message
Minimum (%d) must not be greater than maximum (%d)
What it means
BatchElements.Builder.validate() rejects a BatchConfig whose minBatchSize exceeds maxBatchSize; build() calls validate so an inconsistent builder throws IllegalArgumentException before the transform is constructed.
Solutions
- Ensure minBatchSize <= maxBatchSize in the builder before build()
- Clamp or swap the values programmatically when reading from config
- Add a config-level check at startup so invalid ranges fail early
Example fix
// before BatchElements.<T>withMaxBatchSize(100).withMinBatchSize(200) // after BatchElements.<T>withMaxBatchSize(200).withMinBatchSize(100)
Defensive patterns
Strategy: validation
Validate before calling
if (minBatchSize > maxBatchSize) throw new IllegalArgumentException("minBatchSize (" + minBatchSize + ") must be <= maxBatchSize (" + maxBatchSize + ")"); Try / catch
try {
return BatchElements.<T>withMaxBatchSize(max).withMinBatchSize(min);
} catch (IllegalArgumentException e) {
LOG.error("Invalid batch size range", e); throw e;
} Prevention
- Always set maxBatchSize before or together with minBatchSize
- Validate config-derived sizes at load time
- Keep constants in one place so min/max stay consistent
When it happens
Trigger: Calling withMinBatchSize(n) larger than the current withMaxBatchSize(m) (n > m) and then build().
Common situations: Setting min after max without re-checking; constructing sizes from config where user-provided min > default max; copying builder options between transforms with different ranges.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- targetBatchDurationSecs
- targetBatchDurationSecsWithFixedCost
- targetBatchOverhead ( ) must be between 0 and 1
- Batch size is too large! It should be smaller or equal than
- Column delimiter should be set if headers are present.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/e70a80c4e8b9e96d.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/BatchElements.java:242
*
* <p>This introduces controlled randomness to avoid converging to a single batch size and
* improves robustness of estimation.
*
* @param variance relative deviation (e.g., 0.25 for ±25%)
*/
public Builder withVariance(double variance) {
this.variance = variance;
return this;
}
public BatchConfig build() {
validate();
return new BatchConfig(this);
}
private void validate() {
if (minBatchSize > maxBatchSize) {
throw new IllegalArgumentException(
String.format(
"Minimum (%d) must not be greater than maximum (%d)",
minBatchSize, maxBatchSize));
}
if (!(targetBatchOverhead > 0 && targetBatchOverhead <= 1)) {
throw new IllegalArgumentException(
String.format(
"targetBatchOverhead (%f) must be between 0 and 1", targetBatchOverhead));
}
if (targetBatchDurationSecs <= 0) {
throw new IllegalArgumentException(
String.format(
"targetBatchDurationSecs (%f) must be positive", targetBatchDurationSecs));
}
if (targetBatchDurationSecsWithFixedCost != -1
&& targetBatchDurationSecsWithFixedCost <= 0) {
throw new IllegalArgumentException(
String.format(View on GitHub (pinned to 12126d8942)