{"record":{"id":"1fd94567cfd49530","repo":"apache/beam","slug":"minimum-s-must-not-be-greater-than-maximum-s","errorCode":null,"errorMessage":"Minimum (%s) must not be greater than maximum (%s)","messagePattern":"Minimum \\((.+?)\\) must not be greater than maximum \\((.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/util.py","lineNumber":521,"sourceCode":"  \"\"\"Estimates the best size for batches given historical timing.\n  \"\"\"\n\n  _MAX_DATA_POINTS = 100\n  _MAX_GROWTH_FACTOR = 2\n\n  def __init__(\n      self,\n      min_batch_size=1,\n      max_batch_size=10000,\n      target_batch_overhead=.05,\n      target_batch_duration_secs=10,\n      target_batch_duration_secs_including_fixed_cost=None,\n      variance=0.25,\n      clock=time.time,\n      ignore_first_n_seen_per_batch_size=0,\n      record_metrics=True):\n    if min_batch_size > max_batch_size:\n      raise ValueError(\n          \"Minimum (%s) must not be greater than maximum (%s)\" %\n          (min_batch_size, max_batch_size))\n    if target_batch_overhead and not 0 < target_batch_overhead <= 1:\n      raise ValueError(\n          \"target_batch_overhead (%s) must be between 0 and 1\" %\n          (target_batch_overhead))\n    if target_batch_duration_secs and target_batch_duration_secs <= 0:\n      raise ValueError(\n          \"target_batch_duration_secs (%s) must be positive\" %\n          (target_batch_duration_secs))\n    if (target_batch_duration_secs_including_fixed_cost and\n        target_batch_duration_secs_including_fixed_cost <= 0):\n      raise ValueError(\n          \"target_batch_duration_secs_including_fixed_cost \"\n          \"(%s) must be positive\" %\n          (target_batch_duration_secs_including_fixed_cost))\n    if not (target_batch_overhead or target_batch_duration_secs or\n            target_batch_duration_secs_including_fixed_cost):","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/util.py#L503-L539","documentation":"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.","triggerScenarios":"Calling BatchElements(min_batch_size=N, max_batch_size=M) with N > M, e.g. min_batch_size=100, max_batch_size=10.","commonSituations":"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.","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."],"exampleFix":"// before\nbeam.BatchElements(min_batch_size=500, max_batch_size=100)\n\n// after\nbeam.BatchElements(min_batch_size=100, max_batch_size=500)","handlingStrategy":"validation","validationCode":"if min_batch_size > max_batch_size:\n    raise ValueError(f'min_batch_size ({min_batch_size}) must be <= max_batch_size ({max_batch_size})')","typeGuard":"def valid_batch_range(lo, hi):\n    return isinstance(lo, int) and isinstance(hi, int) and 0 < lo <= hi","tryCatchPattern":"try:\n    t = beam.BatchElements(min_batch_size=cfg.min, max_batch_size=cfg.max, target_batch_overhead=0.05)\nexcept ValueError as e:\n    logging.error('invalid BatchElements config: %s', e)\n    t = beam.BatchElements(target_batch_overhead=0.05)  # safe defaults","preventionTips":["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."],"tags":["python","apache-beam","batchelements","config-validation"],"backgroundTag":"invalid-config-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}