{"record":{"id":"0a96ce01f377ca09","repo":"apache/beam","slug":"targetbatchdurationsecs-f-must-be-positive","errorCode":null,"errorMessage":"targetBatchDurationSecs (%f) must be positive","messagePattern":"targetBatchDurationSecs \\((.+?)\\) must be positive","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/BatchElements.java","lineNumber":253,"sourceCode":"      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(\n                  \"targetBatchDurationSecsWithFixedCost (%f) must be positive\",\n                  targetBatchDurationSecsWithFixedCost));\n        }\n      }\n    }\n  }\n\n  static class BatchSizeEstimator implements Serializable {\n    private List<long[]> data = new ArrayList<>();\n    private final BatchConfig config;\n    private @Nullable Integer replayLastBatchSize = null; // null = no replay pending","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/BatchElements.java#L235-L271","documentation":"BatchConfig.validate rejected targetBatchDurationSecs because it was <= 0. This config sets how long the BatchElements inserter may hold elements to reach a target batch size; a non-positive duration would stall batches forever, so build() fails fast during validation.","triggerScenarios":"Calling withTargetBatchDuration(x) with x <= 0 then build().","commonSituations":"Config value of 0 from an unset/zeroed settings field; seconds/milliseconds unit confusion yielding 0.0; typo passing a negative 'speedup' constant.","solutions":["Pass a positive duration in seconds (e.g. 0.1, 1.0)","Default the value when config is 0 or unset before building","Validate durations at config-load time"],"exampleFix":"// before\n.withTargetBatchDuration(0)\n// after\n.withTargetBatchDuration(1.0)","handlingStrategy":"validation","validationCode":"if (!(targetBatchDurationSecs > 0)) throw new IllegalArgumentException(\"targetBatchDurationSecs must be > 0, got \" + targetBatchDurationSecs);","typeGuard":null,"tryCatchPattern":"try {\n  return builder.withTargetBatchDuration(d);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"Batch duration must be positive seconds\", e); throw e;\n}","preventionTips":["Default unset/zero config to a sane positive value (e.g. 1.0s)","Watch for unit conversions that round tiny durations to 0.0","Validate all duration configs at startup"],"tags":["java","builder-validation","batching"],"backgroundTag":"value-out-of-range","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"}