{"record":{"id":"5eed94ad57bca30e","repo":"apache/beam","slug":"target-batch-duration-secs-including-fixed-cost-s-must-be","errorCode":null,"errorMessage":"target_batch_duration_secs_including_fixed_cost (%s) must be positive","messagePattern":"target_batch_duration_secs_including_fixed_cost \\((.+?)\\) must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/util.py","lineNumber":534,"sourceCode":"      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):\n      raise ValueError(\n          \"At least one of target_batch_overhead or \"\n          \"target_batch_duration_secs or \"\n          \"target_batch_duration_secs_including_fixed_cost must be positive.\")\n    if ignore_first_n_seen_per_batch_size < 0:\n      raise ValueError(\n          'ignore_first_n_seen_per_batch_size (%s) must be non '\n          'negative' % (ignore_first_n_seen_per_batch_size))\n    self._min_batch_size = min_batch_size\n    self._max_batch_size = max_batch_size\n    self._target_batch_overhead = target_batch_overhead\n    self._target_batch_duration_secs = target_batch_duration_secs\n    self._target_batch_duration_secs_including_fixed_cost = (","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/util.py#L516-L552","documentation":"Raised in _BatchSizeEstimator (BatchElements) __init__ when target_batch_duration_secs_including_fixed_cost is provided but <= 0. Like target_batch_duration_secs, this per-batch wall-clock goal must be strictly positive because it drives the adaptive batch-size search.","triggerScenarios":"BatchElements(target_batch_duration_secs_including_fixed_cost=0) or negative; passing an unconverted timedelta or a computed value that rounded down to 0.","commonSituations":"Same as the plain duration variant: timedelta passed raw, subtraction yielding 0, config sentinel 0 for 'disabled'.","solutions":["Pass a strictly positive duration in seconds.","Convert timedeltas via .total_seconds() and verify it is > 0.","Omit the parameter (None) instead of passing 0 when the option should be disabled."],"exampleFix":"// before\nbeam.BatchElements(target_batch_duration_secs_including_fixed_cost=0)\n\n// after\nbeam.BatchElements(target_batch_duration_secs_including_fixed_cost=0.5)","handlingStrategy":"validation","validationCode":"if target_batch_duration_secs_including_fixed_cost is not None and target_batch_duration_secs_including_fixed_cost <= 0:\n    raise ValueError('target_batch_duration_secs_including_fixed_cost must be > 0 seconds')","typeGuard":"def valid_fixed_cost_duration(x):\n    return x is None or (isinstance(x, (int, float)) and x > 0)","tryCatchPattern":"try:\n    t = beam.BatchElements(target_batch_duration_secs_including_fixed_cost=d)\nexcept ValueError as e:\n    logging.error('bad fixed-cost duration %r: %s', d, e)\n    raise","preventionTips":["Convert timedelta values with .total_seconds().","Never pass 0 as a 'disabled' sentinel; omit the argument instead.","Include this parameter in shared config validation with the other target_* fields."],"tags":["python","apache-beam","batchelements","config-validation"],"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"}