Skip to content

[Bug]: Improve the validation error when both chain and input are given for Beam YAML #34690

@liferoad

Description

@liferoad

What happened?

Internal bug number: 391388913

Test YAML:

pipeline:
  type: chain
  transforms:
    - type: Create
      config:
        elements: [1, 2, 3]
    - type: LogForTesting
      input: Create

When running this with python -m apache_beam.yaml.main --yaml_pipeline_file=test_chain.yaml, got this error:

INFO:root:Missing pipeline option (runner). Executing pipeline using the default runner: DirectRunner.
Building pipeline...
Traceback (most recent call last):
  File "/Users/xqhu/miniconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/xqhu/miniconda3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/xqhu/PlayGround/yaml/venv1/lib/python3.10/site-packages/apache_beam/yaml/main.py", line 183, in <module>
    run()
  File "/Users/xqhu/PlayGround/yaml/venv1/lib/python3.10/site-packages/apache_beam/yaml/main.py", line 129, in run
    constructor(p)
  File "/Users/xqhu/PlayGround/yaml/venv1/lib/python3.10/site-packages/apache_beam/yaml/main.py", line 170, in constructor
    yaml_transform.expand_pipeline(
  File "/Users/xqhu/PlayGround/yaml/venv1/lib/python3.10/site-packages/apache_beam/yaml/yaml_transform.py", line 1114, in expand_pipeline
    validate_against_schema(pipeline_spec, validate_schema)
  File "/Users/xqhu/PlayGround/yaml/venv1/lib/python3.10/site-packages/apache_beam/yaml/yaml_transform.py", line 88, in validate_against_schema
    raise exn
  File "/Users/xqhu/PlayGround/yaml/venv1/lib/python3.10/site-packages/apache_beam/yaml/yaml_transform.py", line 85, in validate_against_schema
    jsonschema.validate(pipeline, pipeline_schema(strictness))
  File "/Users/xqhu/PlayGround/yaml/venv1/lib/python3.10/site-packages/jsonschema/validators.py", line 1332, in validate
    raise error
jsonschema.exceptions.ValidationError: 'Create' should not be valid under {} around line 8

Failed validating 'not' in schema['properties']['pipeline']['allOf'][2]['then']['properties']['transforms']['items']['properties']['input']:
    {'not': {}}

On instance['pipeline']['transforms'][1]['input']:
    'Create'

What should happen?

A better validation error that indicates both chain and input cannot be given.

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components

  • Component: Python SDK
  • Component: Java SDK
  • Component: Go SDK
  • Component: Typescript SDK
  • Component: IO connector
  • Component: Beam YAML
  • Component: Beam examples
  • Component: Beam playground
  • Component: Beam katas
  • Component: Website
  • Component: Infrastructure
  • Component: Spark Runner
  • Component: Flink Runner
  • Component: Samza Runner
  • Component: Twister2 Runner
  • Component: Hazelcast Jet Runner
  • Component: Google Cloud Dataflow Runner

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions