apache/beam · error · ValueError
At most one of --create_test and --fix_tests may be specifie
Error message
At most one of --create_test and --fix_tests may be specified.
What it means
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.
Source
Thrown at sdks/python/apache_beam/yaml/main.py:169
return pipeline_yaml
def run(argv=None):
options, constructor, display_data = build_pipeline_components_from_argv(argv)
with beam.Pipeline(options=options, display_data=display_data) as p:
print('Building pipeline...')
constructor(p)
print('Running pipeline...')
def run_tests(argv=None, exit=True):
known_args, pipeline_args, _, pipeline_yaml = _build_pipeline_yaml_from_argv(
argv)
pipeline_spec = yaml.load(pipeline_yaml, Loader=yaml_transform.SafeLineLoader)
options = _build_pipeline_options(pipeline_spec, pipeline_args)
if known_args.create_test and known_args.fix_tests:
raise ValueError(
'At most one of --create_test and --fix_tests may be specified.')
elif known_args.create_test:
result = unittest.TestResult()
tests = []
else:
if known_args.test_suite:
with open(known_args.test_suite) as fin:
test_suite_holder = yaml.load(
fin, Loader=yaml_transform.SafeLineLoader) or {}
else:
test_suite_holder = pipeline_spec
test_specs = test_suite_holder.get('tests', [])
if not isinstance(test_specs, list):
raise TypeError('tests attribute must be a list of test specifications.')
elif not test_specs:
raise RuntimeError(
'No tests found. '
"If you haven't added a set of tests yet, you can get started by "View on GitHub (pinned to 12126d8942)
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.
Example fix
# before python -m apache_beam.yaml.main --yaml_pipeline_file p.yaml --create_test --fix_tests # after python -m apache_beam.yaml.main --yaml_pipeline_file p.yaml --fix_tests
Defensive patterns
Strategy: validation
Validate before calling
import sys
flags = sys.argv
assert not ('--create_test' in flags and '--fix_tests' in flags), 'choose --create_test OR --fix_tests' Type guard
def has_conflicting_test_flags(argv):
return '--create_test' in argv and '--fix_tests' in argv Try / catch
try:
apache_beam.yaml.main.run(argv)
except ValueError as e:
if 'At most one of --create_test' in str(e):
parser.error('--create_test and --fix_tests are mutually exclusive')
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- Exactly one of yaml_pipeline or yaml_pipeline_file must be s
- tests attribute must be a list of test specifications.
- f'Non-mocked source {name_or_type} at line {yaml_transform.S
- f'Test specification must be an object, got {type(test_spec)
- f'allowed_sources of test specification {identifier} must be
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/1de06bb3aa60dc96.
Report an issue: GitHub.