apache/beam · error · ValueError

%s: the result is expected to be an integer, not None.

Error message

%s: the result is expected to be an integer, not None.

What it means

DistributionMetric.__init__ extracts a numeric field (e.g. mean, sum, min, max, count) from a distribution metric result and passes it to the base Metric. If that field is None — the runner did not report the requested statistic — it raises ValueError since the resulting metric value must be an integer.

Source

Thrown at sdks/python/apache_beam/testing/load_tests/load_test_metrics_utils.py:392

class DistributionMetric(Metric):
  """The Distribution Metric in ready-to-publish format.

  Args:
    dist_metric (object): distribution metric object from MetricResult
    submit_timestamp (float): date-time of saving metric to database
    metric_id (uuid): unique id to identify test run
  """
  def __init__(self, dist_metric, submit_timestamp, metric_id, metric_type):
    custom_label = dist_metric.key.metric.namespace + \
                   '_' + parse_step(dist_metric.key.step) + \
                   '_' + metric_type + \
                   '_' + dist_metric.key.metric.name
    value = getattr(dist_metric.result, metric_type)
    if value is None:
      msg = '%s: the result is expected to be an integer, ' \
            'not None.' % custom_label
      _LOGGER.debug(msg)
      raise ValueError(msg)
    super() \
      .__init__(submit_timestamp, metric_id, value, dist_metric, custom_label)


class RuntimeMetric(Metric):
  """The Distribution Metric in ready-to-publish format.

  Args:
    runtime_list: list of distributions metrics from MetricResult
      with runtime name
    metric_id(uuid): unique id to identify test run
  """
  def __init__(self, runtime_list, metric_id):
    value = self._prepare_runtime_metrics(runtime_list)
    submit_timestamp = time.time()
    # Label does not include step name, because it is one value calculated
    # out of many steps
    label = runtime_list[0].key.metric.namespace + \

View on GitHub (pinned to 12126d8942)

Solutions

  1. Check the distribution result field for None before constructing the DistributionMetric and skip it
  2. Ensure the metric was actually updated in the pipeline (distributions with no recorded values report None fields)
  3. Use a metric_type guaranteed by the runner (e.g. 'sum' or 'count') instead of one that may be absent

Example fix

# before
value = getattr(dist_metric.result, metric_type)
metric = DistributionMetric(submit_timestamp, dist_metric, metric_type, custom_label)  # raises if None
# after
value = getattr(dist_metric.result, metric_type)
if value is not None:
  metric = DistributionMetric(submit_timestamp, dist_metric, metric_type, custom_label)
else:
  _LOGGER.warning('Skipping %s: no value reported', metric_type)
Defensive patterns

Strategy: try-catch

Validate before calling

value = getattr(dist_metric.result, metric_type, None)
if value is None:
    logging.warning('Skipping %s: runner reported no value', metric_type)
    return None  # skip constructing DistributionMetric

Try / catch

try:
    metric = DistributionMetric(submit_timestamp, dist_metric, metric_type, custom_label)
except ValueError as e:
    if 'expected to be an integer' in str(e):
        logging.debug('No value for %s; skipping metric', metric_type)
        metric = None
    else:
        raise

Prevention

When it happens

Trigger: Constructing a DistributionMetric with a metric_type for which the runner's DistributionResult has no value (None), e.g. requesting a statistic not populated by the runner, or on a distribution that never received updates.

Common situations: Load-test metric extraction after a pipeline run where the distribution had zero updates; requesting an unsupported/absent metric_type from the distribution result; runners that report incomplete distribution results.

Related errors


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