apache/beam · error · ValueError

'Missing value for update of %s' % self.typed_metric_name.fa

Error message

'Missing value for update of %s' % self.typed_metric_name.fast_name

What it means

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.

Source

Thrown at sdks/python/apache_beam/metrics/execution.py:221


class MetricUpdater(object):
  """A callable that updates the metric as quickly as possible."""
  def __init__(
      self,
      cell_type,  # type: Union[Type[MetricCell], MetricCellFactory]
      metric_name,  # type: Union[str, MetricName]
      default_value=None,
      process_wide=False):
    self.process_wide = process_wide
    self.typed_metric_name = _TypedMetricName(cell_type, metric_name)
    self.default_value = default_value

  def __call__(self, value=_DEFAULT):
    # type: (Any) -> None
    if value is _DEFAULT:
      if self.default_value is _DEFAULT:
        raise ValueError(
            'Missing value for update of %s' % self.typed_metric_name.fast_name)
      value = self.default_value
    if self.process_wide:
      MetricsEnvironment.process_wide_container().get_metric_cell(
          self.typed_metric_name).update(value)
    else:
      tracker = get_current_tracker()
      if tracker is not None:
        tracker.update_metric(self.typed_metric_name, value)

  def __reduce__(self):
    return MetricUpdater, (
        self.typed_metric_name.cell_type,
        self.typed_metric_name.metric_name,
        self.default_value)


class MetricsContainer(object):

View on GitHub (pinned to 12126d8942)

Solutions

  1. Pass the value explicitly: my_counter(1).
  2. Provide a default_value when creating the metric so calling with no argument is valid.
  3. If the metric should not be callable, use Metrics.counter(...) and cell.update(value) instead.

Example fix

counter = Metrics.process_wide_counter('ns', 'hits')
- counter()
+ counter(1)
# or
+ counter = Metrics.process_wide_counter('ns', 'hits', default_value=0)
Defensive patterns

Strategy: validation

Validate before calling

if process_wide_metric.default_value is Metrics._DEFAULT:
    call_with_value = True  # must pass an explicit value

Type guard

def has_default(metric):
    return getattr(metric, 'default_value', None) is not getattr(Metrics, '_DEFAULT', object())

Try / catch

try:
    metric()
except ValueError:
    metric(default_value)

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/1e95ff649c8e9205. Report an issue: GitHub.