{"record":{"id":"1de06bb3aa60dc96","repo":"apache/beam","slug":"at-most-one-of-create-test-and-fix-tests-may-be-specified","errorCode":null,"errorMessage":"At most one of --create_test and --fix_tests may be specified.","messagePattern":"At most one of --create_test and --fix_tests may be specified\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/main.py","lineNumber":169,"sourceCode":"  return pipeline_yaml\n\n\ndef run(argv=None):\n  options, constructor, display_data = build_pipeline_components_from_argv(argv)\n  with beam.Pipeline(options=options, display_data=display_data) as p:\n    print('Building pipeline...')\n    constructor(p)\n    print('Running pipeline...')\n\n\ndef run_tests(argv=None, exit=True):\n  known_args, pipeline_args, _, pipeline_yaml = _build_pipeline_yaml_from_argv(\n      argv)\n  pipeline_spec = yaml.load(pipeline_yaml, Loader=yaml_transform.SafeLineLoader)\n  options = _build_pipeline_options(pipeline_spec, pipeline_args)\n\n  if known_args.create_test and known_args.fix_tests:\n    raise ValueError(\n        'At most one of --create_test and --fix_tests may be specified.')\n  elif known_args.create_test:\n    result = unittest.TestResult()\n    tests = []\n  else:\n    if known_args.test_suite:\n      with open(known_args.test_suite) as fin:\n        test_suite_holder = yaml.load(\n            fin, Loader=yaml_transform.SafeLineLoader) or {}\n    else:\n      test_suite_holder = pipeline_spec\n    test_specs = test_suite_holder.get('tests', [])\n    if not isinstance(test_specs, list):\n      raise TypeError('tests attribute must be a list of test specifications.')\n    elif not test_specs:\n      raise RuntimeError(\n          'No tests found. '\n          \"If you haven't added a set of tests yet, you can get started by \"","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/main.py#L151-L187","documentation":"run_tests supports generating a new test (--create_test) or updating existing tests (--fix_tests), but not both simultaneously, since the two modes are mutually exclusive workflows. Passing both raises this ValueError.","triggerScenarios":"Invoking apache_beam.yaml.main with both --create_test and --fix_tests flags set (e.g. `--create_test --fix_tests`), triggering the check in run_tests.","commonSituations":"Alias/scripts that always append --fix_tests while a user also passes --create_test; confusion between the two test-authoring modes; CI matrices enabling both toggles.","solutions":["Choose one mode: drop --fix_tests if you want to generate a fresh test, or drop --create_test to update existing tests.","In scripts, gate each flag on distinct user intent (e.g. MODE=create|fix) so both are never emitted.","Wrap the call in try/except ValueError to translate the message into a friendly CLI usage error.","Document the mutual exclusivity in your team's pipeline-testing docs/aliases."],"exampleFix":"# before\npython -m apache_beam.yaml.main --yaml_pipeline_file p.yaml --create_test --fix_tests\n# after\npython -m apache_beam.yaml.main --yaml_pipeline_file p.yaml --fix_tests","handlingStrategy":"validation","validationCode":"import sys\nflags = sys.argv\nassert not ('--create_test' in flags and '--fix_tests' in flags), 'choose --create_test OR --fix_tests'","typeGuard":"def has_conflicting_test_flags(argv):\n    return '--create_test' in argv and '--fix_tests' in argv","tryCatchPattern":"try:\n    apache_beam.yaml.main.run(argv)\nexcept ValueError as e:\n    if 'At most one of --create_test' in str(e):\n        parser.error('--create_test and --fix_tests are mutually exclusive')\n    raise","preventionTips":["Expose a single MODE=create|fix parameter in wrapper scripts instead of raw flags.","Never append both flags in CI matrices or make targets.","Document the two test-authoring modes separately in team docs."],"tags":["python","apache-beam","yaml","cli","testing"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}