apache/beam · error · TypeError
f'{attr_type} of test specification {identifier} must be a l
Error message
f'{attr_type} of test specification {identifier} must be a list, got {type(attr_type)}' What it means
A test specification attribute that must be a list of named element groups (mock_inputs, mock_outputs, expected_outputs, or expected_inputs) was supplied as some other type. validate_test_spec iterates these four attributes and this guard fires on the first one that is not a Python list, naming the offending attr_type and test identifier. Note the message interpolates type(attr_type) (the attribute name's type) rather than the actual value's type, so it always reports <class 'str'>.
Source
Thrown at sdks/python/apache_beam/yaml/yaml_testing.py:179
'name',
'mock_inputs',
'mock_outputs',
'expected_outputs',
'expected_inputs',
'allowed_sources',
])
if unknown_attrs:
raise ValueError(
f'test specification {identifier} '
f'has unknown attributes {list(unknown_attrs)}')
for attr_type in ('mock_inputs',
'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} 'View on GitHub (pinned to 12126d8942)
Solutions
- Set the offending attribute (e.g. mock_inputs) to a YAML/Python list of mappings, each with 'name' and 'elements' keys
- If only one entry is needed, still wrap it in a list: mock_inputs: [{name: ..., elements: [...]}]
- Check for YAML indentation errors that made the attribute parse as a scalar or map instead of a sequence
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at sdks/python/apache_beam/yaml/yaml_testing.py:179 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/5ef63b8028925162.
Report an issue: GitHub.