apache/beam · error · RuntimeError

In-file test fixing not yet supported for templated…

Error message

In-file test fixing not yet supported for templated pipelines. Please use the --test_suite flag.

What it means

Raised by update_tests when the test-suite file is the same as the templated pipeline file and the pipeline YAML on disk differs from the pipeline YAML that was loaded/transformed. In-file test fixing for templated pipelines isn't supported, so Beam refuses to overwrite the file.

Solutions

  1. Split tests into a separate file and pass it via --test_suite instead of --yaml_pipeline_file.
  2. Ensure the on-disk YAML matches the pipeline exactly (avoid pre-transformation) if in-file fixing is intended.
  3. Disable test fixing for templated pipelines and run tests in read-only mode.

Example fix

// before
python -m apache_beam.yaml.main --yaml_pipeline_file template.yaml --fix_tests
// after
python -m apache_beam.yaml.main --test_suite tests.yaml --fix_tests
Defensive patterns

Strategy: validation

Validate before calling

import yaml
on_disk = open(path).read().strip()
if path == known_args.yaml_pipeline_file and pipeline_yaml.strip() != on_disk:
    raise SystemExit('Pipeline file was transformed; use a separate --test_suite file for fixing')

Type guard

def safe_for_inplace_fix(path, pipeline_yaml, known_args) -> bool:
    return path != getattr(known_args, 'yaml_pipeline_file', None) or pipeline_yaml.strip() == open(path).read().strip()

Try / catch

try:
    update_tests(...)
except RuntimeError as e:
    if 'In-file test fixing not yet supported' in str(e):
        export_tests_to_separate_suite_file(); retry_with_test_suite_flag()
    else:
        raise

Prevention

When it happens

Trigger: Using --yaml_pipeline_file with test fixing (--fix_tests) where pipeline_yaml (possibly normalized/transformed) no longer matches the original file contents verbatim (whitespace-stripped).

Common situations: Developers point --yaml_pipeline_file at a templated pipeline and expect fixes to be written in place; template generation rewrote the YAML so the on-disk text diverges from the in-memory pipeline.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at sdks/python/apache_beam/yaml/main.py:225


def update_tests(known_args, pipeline_yaml, pipeline_spec, options, tests):
  if known_args.test_suite:
    path = known_args.test_suite
    if not os.path.exists(path) and known_args.create_test:
      with open(path, 'w') as fout:
        fout.write('tests: []')
  elif known_args.yaml_pipeline_file:
    path = known_args.yaml_pipeline_file
  else:
    raise RuntimeError(
        'Test fixing only supported for file-backed tests. '
        'Please use the --test_suite flag.')
  with open(path) as fin:
    original_yaml = fin.read()
  if path == known_args.yaml_pipeline_file and pipeline_yaml.strip(
  ) != original_yaml.strip():
    raise RuntimeError(
        'In-file test fixing not yet supported for templated pipelines. '
        'Please use the --test_suite flag.')
  updated_spec = yaml.load(original_yaml, Loader=yaml.SafeLoader) or {}

  if known_args.fix_tests:
    updated_spec['tests'] = [test.fixed_test() for test in tests]

  if known_args.create_test:
    if 'tests' not in updated_spec:
      updated_spec['tests'] = []
    updated_spec['tests'].append(
        yaml_testing.create_test(pipeline_spec, options))

  updated_yaml = yaml_utils.patch_yaml(original_yaml, updated_spec)
  with open(path, 'w') as fout:
    fout.write(updated_yaml)

View on GitHub (pinned to 12126d8942)