{"record":{"id":"973e31a555e6cac3","repo":"apache/beam","slug":"test-fixing-only-supported-for-file-backed-tests-please-use","errorCode":null,"errorMessage":"Test fixing only supported for file-backed tests. Please use the --test_suite flag.","messagePattern":"Test fixing only supported for file-backed tests\\. Please use the --test_suite flag\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/main.py","lineNumber":218,"sourceCode":"\n  if exit:\n    # emulates unittest.main()\n    sys.exit(0 if result.wasSuccessful() else 1)\n  else:\n    if not result.wasSuccessful():\n      raise RuntimeError(result)\n\n\ndef update_tests(known_args, pipeline_yaml, pipeline_spec, options, tests):\n  if known_args.test_suite:\n    path = known_args.test_suite\n    if not os.path.exists(path) and known_args.create_test:\n      with open(path, 'w') as fout:\n        fout.write('tests: []')\n  elif known_args.yaml_pipeline_file:\n    path = known_args.yaml_pipeline_file\n  else:\n    raise RuntimeError(\n        'Test fixing only supported for file-backed tests. '\n        'Please use the --test_suite flag.')\n  with open(path) as fin:\n    original_yaml = fin.read()\n  if path == known_args.yaml_pipeline_file and pipeline_yaml.strip(\n  ) != original_yaml.strip():\n    raise RuntimeError(\n        'In-file test fixing not yet supported for templated pipelines. '\n        'Please use the --test_suite flag.')\n  updated_spec = yaml.load(original_yaml, Loader=yaml.SafeLoader) or {}\n\n  if known_args.fix_tests:\n    updated_spec['tests'] = [test.fixed_test() for test in tests]\n\n  if known_args.create_test:\n    if 'tests' not in updated_spec:\n      updated_spec['tests'] = []\n    updated_spec['tests'].append(","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/main.py#L200-L236","documentation":"Raised by update_tests in apache_beam.yaml.main when test fixing is requested but the tests were supplied inline (e.g. via --yaml_pipeline on the command line) rather than in a file. Auto-fixing rewrites the YAML file on disk, which is only possible when tests are file-backed.","triggerScenarios":"Running with test-fixing flags (--fix_tests or --create_test) where neither --test_suite nor --yaml_pipeline_file points at an existing file — i.e. the pipeline YAML came from a string/inline source with no path to write back to.","commonSituations":"Developers pass the pipeline YAML inline via stdin or --yaml_pipeline while also requesting --fix_tests; CI jobs that generate the pipeline dynamically and then try to fix tests.","solutions":["Write the YAML pipeline (including tests) to a file and pass it via --test_suite.","Remove the --fix_tests/--create_test flag if you don't need the tests written back to disk.","Pipe the YAML into a temp file first, e.g. `beam_yaml > suite.yaml`, then run test fixing against that file."],"exampleFix":"// before\npython -m apache_beam.yaml.main --yaml_pipeline \"pipeline: ...\" --fix_tests\n// after\npython -m apache_beam.yaml.main --test_suite my_pipeline.yaml --fix_tests","handlingStrategy":"validation","validationCode":"import sys\nargs = sys.argv\nif ('--fix_tests' in args or '--create_test' in args) and '--test_suite' not in args and '--yaml_pipeline_file' not in args:\n    raise SystemExit('Test fixing requires a file: pass --test_suite <file.yaml>')","typeGuard":"def is_file_backed(known_args) -> bool:\n    return bool(getattr(known_args, 'test_suite', None) or getattr(known_args, 'yaml_pipeline_file', None))","tryCatchPattern":"try:\n    update_tests(...)\nexcept RuntimeError as e:\n    if 'file-backed tests' in str(e):\n        write_yaml_to_tempfile(pipeline_yaml); retry_with_test_suite_flag()\n    else:\n        raise","preventionTips":["Always materialize inline YAML to a file before enabling --fix_tests","Use --test_suite for all test-fixing workflows","Document in CI that test fixing requires file-backed input"],"tags":["yaml","testing","cli"],"backgroundTag":"missing-required-flag","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}