apache/beam · error · TypeError

f' of test specification missing a elements

Error message

f'{attr_type} {ix} of test specification {identifier} missing a elements'

What it means

An entry in mock_inputs/mock_outputs/expected_outputs/expected_inputs has a 'name' but no 'elements' key. The elements list holds the sample or expected rows for that input/output; without it the test has nothing to inject or assert, so validation fails. Note the message says 'a elements' due to an interpolation typo in the format string.

Solutions

  1. Add an 'elements' key containing the list of rows for that input/output, e.g. elements: [{id: 1}]
  2. Use elements: [] to explicitly assert an empty output
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at sdks/python/apache_beam/yaml/yaml_testing.py:192 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at sdks/python/apache_beam/yaml/yaml_testing.py:192

                    'mock_outputs',
                    'expected_outputs',
                    'expected_inputs'):
    attr = test_spec.get(attr_type, [])
    if not isinstance(attr, list):
      raise TypeError(
          f'{attr_type} of test specification {identifier} '
          f'must be a list, got {type(attr_type)}')
    for ix, attr_item in enumerate(attr):
      if not isinstance(attr_item, dict):
        raise TypeError(
            f'{attr_type} {ix} of test specification {identifier} '
            f'must be an object, got {type(attr_item)}')
      if 'name' not in attr_item:
        raise TypeError(
            f'{attr_type} {ix} of test specification {identifier} '
            f'missing a name')
      if 'elements' not in attr_item:
        raise TypeError(
            f'{attr_type} {ix} of test specification {identifier} '
            f'missing a elements')
      if not isinstance(attr_item['elements'], list):
        raise TypeError(
            f'{attr_type} {ix} of test specification {identifier} '
            f'must be a list, got {type(attr_item["elements"])}')


def inject_test_tranforms(spec, test_spec, fix_failures):
  validate_test_spec(test_spec)
  scope = yaml_transform.LightweightScope(spec['transforms'])

  mocked_inputs_by_id = {
      scope.get_transform_id(mock_input['name']): mock_input
      for mock_input in test_spec.get('mock_inputs', [])
  }

  mocked_outputs_by_id = _composite_key_to_nested({

View on GitHub (pinned to 12126d8942)