apache/beam · error · ValueError
Minimum ( ) must not be greater than maximum ( )
Error message
Minimum (%s) must not be greater than maximum (%s)
What it means
Raised in the _BatchSizeEstimator (BatchElements) __init__ when min_batch_size > max_batch_size. The adaptive batching estimator needs a valid size range; a minimum larger than the maximum makes the range empty and cannot produce batches, so construction fails with ValueError.
Solutions
- Swap or correct the values so min_batch_size <= max_batch_size.
- Validate at the call site: assert min_batch_size <= max_batch_size before constructing BatchElements.
- If bounds come from config, clamp them (min = min(min, max); max = max(min, max)) or fail with a clear config-validation message upstream.
Example fix
// before beam.BatchElements(min_batch_size=500, max_batch_size=100) // after beam.BatchElements(min_batch_size=100, max_batch_size=500)
Defensive patterns
Strategy: validation
Validate before calling
if min_batch_size > max_batch_size:
raise ValueError(f'min_batch_size ({min_batch_size}) must be <= max_batch_size ({max_batch_size})') Type guard
def valid_batch_range(lo, hi):
return isinstance(lo, int) and isinstance(hi, int) and 0 < lo <= hi Try / catch
try:
t = beam.BatchElements(min_batch_size=cfg.min, max_batch_size=cfg.max, target_batch_overhead=0.05)
except ValueError as e:
logging.error('invalid BatchElements config: %s', e)
t = beam.BatchElements(target_batch_overhead=0.05) # safe defaults Prevention
- Keep min/max batch size adjacent in the call so a swap is visually obvious.
- Validate batch-size config at load time, before pipeline construction.
- Use named keyword arguments, never positional, for these parameters.
When it happens
Trigger: Calling BatchElements(min_batch_size=N, max_batch_size=M) with N > M, e.g. min_batch_size=100, max_batch_size=10.
Common situations: Config typo or swapped arguments; computing the bounds from variables whose order got reversed; tuning batch sizes after a workload change and forgetting to keep min <= max.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- bucket_boundaries must be a non-empty sorted list of…
- ignore_first_n_seen_per_batch_size
- target_batch_duration_secs_including_fixed_cost
- target_batch_duration_secs
- target_batch_overhead
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/1fd94567cfd49530.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/transforms/util.py:521
"""Estimates the best size for batches given historical timing.
"""
_MAX_DATA_POINTS = 100
_MAX_GROWTH_FACTOR = 2
def __init__(
self,
min_batch_size=1,
max_batch_size=10000,
target_batch_overhead=.05,
target_batch_duration_secs=10,
target_batch_duration_secs_including_fixed_cost=None,
variance=0.25,
clock=time.time,
ignore_first_n_seen_per_batch_size=0,
record_metrics=True):
if min_batch_size > max_batch_size:
raise ValueError(
"Minimum (%s) must not be greater than maximum (%s)" %
(min_batch_size, max_batch_size))
if target_batch_overhead and not 0 < target_batch_overhead <= 1:
raise ValueError(
"target_batch_overhead (%s) must be between 0 and 1" %
(target_batch_overhead))
if target_batch_duration_secs and target_batch_duration_secs <= 0:
raise ValueError(
"target_batch_duration_secs (%s) must be positive" %
(target_batch_duration_secs))
if (target_batch_duration_secs_including_fixed_cost and
target_batch_duration_secs_including_fixed_cost <= 0):
raise ValueError(
"target_batch_duration_secs_including_fixed_cost "
"(%s) must be positive" %
(target_batch_duration_secs_including_fixed_cost))
if not (target_batch_overhead or target_batch_duration_secs or
target_batch_duration_secs_including_fixed_cost):View on GitHub (pinned to 12126d8942)