{"record":{"id":"1e95ff649c8e9205","repo":"apache/beam","slug":"missing-value-for-update-of-s-self-typed-metric-name-fast","errorCode":null,"errorMessage":"'Missing value for update of %s' % self.typed_metric_name.fast_name","messagePattern":"'Missing value for update of (.+?)' % self\\.typed_metric_name\\.fast_name","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/metrics/execution.py","lineNumber":221,"sourceCode":"\n\nclass MetricUpdater(object):\n  \"\"\"A callable that updates the metric as quickly as possible.\"\"\"\n  def __init__(\n      self,\n      cell_type,  # type: Union[Type[MetricCell], MetricCellFactory]\n      metric_name,  # type: Union[str, MetricName]\n      default_value=None,\n      process_wide=False):\n    self.process_wide = process_wide\n    self.typed_metric_name = _TypedMetricName(cell_type, metric_name)\n    self.default_value = default_value\n\n  def __call__(self, value=_DEFAULT):\n    # type: (Any) -> None\n    if value is _DEFAULT:\n      if self.default_value is _DEFAULT:\n        raise ValueError(\n            'Missing value for update of %s' % self.typed_metric_name.fast_name)\n      value = self.default_value\n    if self.process_wide:\n      MetricsEnvironment.process_wide_container().get_metric_cell(\n          self.typed_metric_name).update(value)\n    else:\n      tracker = get_current_tracker()\n      if tracker is not None:\n        tracker.update_metric(self.typed_metric_name, value)\n\n  def __reduce__(self):\n    return MetricUpdater, (\n        self.typed_metric_name.cell_type,\n        self.typed_metric_name.metric_name,\n        self.default_value)\n\n\nclass MetricsContainer(object):","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/metrics/execution.py#L203-L239","documentation":"A Metric object configured with process_wide=True and no default value was called as a function (metric()) without passing a value. Since neither an argument nor a configured default exists, Beam raises ValueError telling you a value is required for that metric.","triggerScenarios":"Creating Metrics.process_wide_counter(...) (or a metric with default_value left as _DEFAULT) and then calling it with zero arguments: my_counter() instead of my_counter(5).","commonSituations":"Calling a process-wide metric like a setter from telemetry hooks where the value parameter was accidentally dropped; copy-pasting metric call sites where one metric has a default and another does not.","solutions":["Pass the value explicitly: my_counter(1).","Provide a default_value when creating the metric so calling with no argument is valid.","If the metric should not be callable, use Metrics.counter(...) and cell.update(value) instead."],"exampleFix":"counter = Metrics.process_wide_counter('ns', 'hits')\n- counter()\n+ counter(1)\n# or\n+ counter = Metrics.process_wide_counter('ns', 'hits', default_value=0)","handlingStrategy":"validation","validationCode":"if process_wide_metric.default_value is Metrics._DEFAULT:\n    call_with_value = True  # must pass an explicit value","typeGuard":"def has_default(metric):\n    return getattr(metric, 'default_value', None) is not getattr(Metrics, '_DEFAULT', object())","tryCatchPattern":"try:\n    metric()\nexcept ValueError:\n    metric(default_value)","preventionTips":["Always pass a value when calling process-wide metric callables.","Set default_value at metric creation if zero-arg calls are intended.","Don't mix call-style metrics with plain Metrics.counter cell updates in the same code path."],"tags":["python","apache-beam","metrics","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}