{"record":{"id":"e70a80c4e8b9e96d","repo":"apache/beam","slug":"minimum-d-must-not-be-greater-than-maximum-d","errorCode":null,"errorMessage":"Minimum (%d) must not be greater than maximum (%d)","messagePattern":"Minimum \\((.+?)\\) must not be greater than maximum \\((.+?)\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/BatchElements.java","lineNumber":242,"sourceCode":"       *\n       * <p>This introduces controlled randomness to avoid converging to a single batch size and\n       * improves robustness of estimation.\n       *\n       * @param variance relative deviation (e.g., 0.25 for ±25%)\n       */\n      public Builder withVariance(double variance) {\n        this.variance = variance;\n        return this;\n      }\n\n      public BatchConfig build() {\n        validate();\n        return new BatchConfig(this);\n      }\n\n      private void validate() {\n        if (minBatchSize > maxBatchSize) {\n          throw new IllegalArgumentException(\n              String.format(\n                  \"Minimum (%d) must not be greater than maximum (%d)\",\n                  minBatchSize, maxBatchSize));\n        }\n        if (!(targetBatchOverhead > 0 && targetBatchOverhead <= 1)) {\n          throw new IllegalArgumentException(\n              String.format(\n                  \"targetBatchOverhead (%f) must be between 0 and 1\", targetBatchOverhead));\n        }\n        if (targetBatchDurationSecs <= 0) {\n          throw new IllegalArgumentException(\n              String.format(\n                  \"targetBatchDurationSecs (%f) must be positive\", targetBatchDurationSecs));\n        }\n        if (targetBatchDurationSecsWithFixedCost != -1\n            && targetBatchDurationSecsWithFixedCost <= 0) {\n          throw new IllegalArgumentException(\n              String.format(","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/BatchElements.java#L224-L260","documentation":"BatchElements.Builder.validate() rejects a BatchConfig whose minBatchSize exceeds maxBatchSize; build() calls validate so an inconsistent builder throws IllegalArgumentException before the transform is constructed.","triggerScenarios":"Calling withMinBatchSize(n) larger than the current withMaxBatchSize(m) (n > m) and then build().","commonSituations":"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.","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"],"exampleFix":"// before\nBatchElements.<T>withMaxBatchSize(100).withMinBatchSize(200)\n// after\nBatchElements.<T>withMaxBatchSize(200).withMinBatchSize(100)","handlingStrategy":"validation","validationCode":"if (minBatchSize > maxBatchSize) throw new IllegalArgumentException(\"minBatchSize (\" + minBatchSize + \") must be <= maxBatchSize (\" + maxBatchSize + \")\");","typeGuard":null,"tryCatchPattern":"try {\n  return BatchElements.<T>withMaxBatchSize(max).withMinBatchSize(min);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"Invalid batch size range\", e); throw e;\n}","preventionTips":["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"],"tags":["java","builder-validation","batching"],"backgroundTag":"invalid-argument-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"}