apache/beam · error · TypeError
f' of test specification must be a list, got
Error message
f'{attr_type} {ix} of test specification {identifier} must be a list, got {type(attr_item["elements"])}' What it means
The 'elements' field of a test-spec entry is present but is not a list. Elements must be a sequence of row values (mappings or scalars); this guard fires when it was parsed as a scalar or mapping, and reports the actual type of attr_item['elements'].
Solutions
- Wrap the element rows in a list: elements: [{col: val}, ...]
- Fix YAML indentation so each element is a list item under 'elements'
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at sdks/python/apache_beam/yaml/yaml_testing.py:196 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/96de510584d119c6.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/yaml/yaml_testing.py:196
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({
scope.get_transform_id_and_output_name(mock_output['name']): mock_output
for mock_output in test_spec.get('mock_outputs', [])
})
View on GitHub (pinned to 12126d8942)