apache/beam · error · ValueError

f'test specification {identifier} has unknown attributes {li

Error message

f'test specification {identifier} has unknown attributes {list(unknown_attrs)}'

What it means

validate_test_spec whitelists the allowed test-spec attributes (name, mock_inputs, mock_outputs, expected_outputs, expected_inputs, allowed_sources). Any unrecognized key raises a ValueError listing the unknown attributes, catching misspelled or unsupported options early.

Source

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

        f'must be a list, got {type(test_spec["allowed_sources"])}')

  if (not test_spec.get('expected_outputs', []) and
      not test_spec.get('expected_inputs', [])):
    raise ValueError(
        f'test specification {identifier} '
        f'must have at least one expected_outputs or expected_inputs')

  unknown_attrs = set(
      yaml_transform.SafeLineLoader.strip_metadata(test_spec).keys()) - set([
          '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:

View on GitHub (pinned to 12126d8942)

Solutions

  1. Remove the unknown attributes or rename them to the supported set: name, mock_inputs, mock_outputs, expected_outputs, expected_inputs, allowed_sources.
  2. Fix misspellings (e.g. expected_outputs not expected_output).
  3. Check Beam YAML docs for the version's supported test-spec schema.

Example fix

# before
- name: my_test
  expected_output:
    out: [{id: 1}]

# after
- name: my_test
  expected_outputs:
    out: [{id: 1}]
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED = {'name','mock_inputs','mock_outputs','expected_outputs','expected_inputs','allowed_sources'}
unknown = set(test_spec) - ALLOWED
if unknown:
    raise ValueError(f'unknown test attributes: {unknown}')

Type guard

def has_only_known_attrs(spec: dict) -> bool:
    return set(spec) <= {'name','mock_inputs','mock_outputs','expected_outputs','expected_inputs','allowed_sources'}

Try / catch

try:
    validate_test_spec(test_spec)
except ValueError as e:
    logging.error('Unknown test attributes: %s', e)
    raise

Prevention

When it happens

Trigger: Including keys like 'expects', 'mockOutputs', or 'description' in a test spec; misspellings such as 'expected_output' (singular) or 'allow_sources'.

Common situations: Typos in attribute names, camelCase from copying JSON examples, or invented attributes assumed to be supported.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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