{"record":{"id":"9eb02f269ce329b4","repo":"apache/beam","slug":"error-handling-config-is-not-supported-directly-in-the","errorCode":null,"errorMessage":"error_handling config is not supported directly in the output_schema. Please use error_handling config in the transform, if possible, or use ValidateWithSchema transform instead.","messagePattern":"error_handling config is not supported directly in the output_schema\\. Please use error_handling config in the transform, if possible, or use ValidateWithSchema transform instead\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_transform.py","lineNumber":580,"sourceCode":"\n  Args:\n    spec (dict): The `output_schema` specification from the YAML config.\n    outputs (beam.PCollection or dict[str, beam.PCollection]): The output(s)\n      from the transform to be validated.\n    error_handling_spec (dict): The `error_handling` configuration from the\n      original transform.\n\n  Returns:\n    The validated PCollection(s). If error handling is enabled, this will be a\n    dictionary containing the 'good' output and any error outputs.\n\n  Raises:\n    ValueError: If `error_handling` is incorrectly specified within the\n      `output_schema` spec itself, or if the main output of a multi-output\n      transform cannot be determined.\n  \"\"\"\n  if 'error_handling' in spec:\n    raise ValueError(\n        'error_handling config is not supported directly in '\n        'the output_schema. Please use error_handling config in '\n        'the transform, if possible, or use ValidateWithSchema transform '\n        'instead.')\n\n  # Strip metadata such as __line__ and __uuid__ as these will interfere with\n  # the validation downstream.\n  clean_schema = SafeLineLoader.strip_metadata(spec)\n\n  # If no error handling is specified for the main transform, warn the user\n  # that the pipeline may fail if any output data fails the output schema\n  # validation.\n  if not error_handling_spec:\n    _LOGGER.warning(\"Output_schema config is attached to a transform that has \"\\\n    \"no error_handling config specified. Any failures validating on output\" \\\n    \"schema will fail the pipeline unless the user specifies an\" \\\n    \"error_handling config on a capable transform. Alternatively, you can \" \\\n    \"remove the output_schema config on this transform and add a \" \\","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_transform.py#L562-L598","documentation":"expand_output_schema_transform validates a transform's outputs against an output_schema. Error handling (where failed rows go) must be configured on the transform itself, not nested inside the output_schema block; putting 'error_handling' in output_schema is rejected with this ValueError.","triggerScenarios":"A YAML spec where 'error_handling:' is placed under 'output_schema:' of a transform, e.g. output_schema: {schema: ..., error_handling: {...}}, instead of at the transform's top-level config alongside output_schema.","commonSituations":"Copy-pasting an error_handling block from a ValidateWithSchema example into the wrong nesting level; misunderstanding docs that show error_handling as a sibling of output_schema.","solutions":["Move the error_handling block out of output_schema to the transform's own config level (sibling of output_schema).","Alternatively, replace the transform with an explicit ValidateWithSchema transform that owns the error_handling config.","Re-run the pipeline after restructuring the YAML."],"exampleFix":"// before\n- type: MapToFields\n  config:\n    output_schema:\n      schema: 'id: INTEGER'\n      error_handling: {output: errors}\n// after\n- type: MapToFields\n  config:\n    error_handling: {output: errors}\n    output_schema:\n      schema: 'id: INTEGER'","handlingStrategy":"validation","validationCode":"def check_output_schema_nesting(spec):\n    os_spec = spec.get('config', {}).get('output_schema', {})\n    if 'error_handling' in os_spec:\n        raise ValueError(\"Move 'error_handling' to the transform config level, not inside output_schema\")","typeGuard":"def error_handling_is_top_level(spec) -> bool:\n    cfg = spec.get('config', {})\n    return 'error_handling' not in cfg.get('output_schema', {})","tryCatchPattern":"try:\n    expand_transform(spec, scope)\nexcept ValueError as e:\n    if 'error_handling config is not supported' in str(e):\n        print('Relocate error_handling block in YAML')\n    else:\n        raise","preventionTips":["Keep error_handling as a sibling of output_schema, not nested in it.","Validate YAML structure in CI before running pipelines.","Refer to ValidateWithSchema examples for correct error_handling placement."],"tags":["python","apache-beam","yaml","config"],"backgroundTag":"invalid-config-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}