{"record":{"id":"116543b79f7e2ebf","repo":"apache/beam","slug":"the-input-to-this-transform-does-not-appear-to-be-an-error","errorCode":null,"errorMessage":"The input to this transform does not appear to be an error output.  Expected a schema'd input with a field named 'msg' or 'message' or 'exception'","messagePattern":"The input to this transform does not appear to be an error output\\.  Expected a schema'd input with a field named 'msg' or 'message' or 'exception'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_mapping.py","lineNumber":492,"sourceCode":"  _ERROR_FIELD_NAMES = ('failed_row', 'element', 'record')\n\n  def __init__(self):\n    super().__init__(label=None)\n\n  def expand(self, pcoll):\n    try:\n      existing_fields = {\n          fld.name: fld.type\n          for fld in schema_from_element_type(pcoll.element_type).fields\n      }\n    except TypeError:\n      fld = None\n    else:\n      for fld in self._ERROR_FIELD_NAMES:\n        if fld in existing_fields:\n          break\n      else:\n        raise ValueError(\n            'The input to this transform does not appear to be an error ' +\n            \"output.  Expected a schema'd input with a field named \" +\n            ' or '.join(repr(fld) for fld in self._ERROR_FIELD_NAMES))\n\n    if fld is None:\n      # This handles with_exception_handling() that returns bare tuples.\n      return pcoll | beam.Map(lambda x: x[0])\n    else:\n      return pcoll | beam.Map(lambda x: getattr(x, fld)).with_output_types(\n          typing_from_runner_api(existing_fields[fld]))\n\n\nclass Validate(beam.PTransform):\n  \"\"\"Validates each element of a PCollection against a json schema.\n\n  Args:\n      schema: A json schema against which to validate each element.\n      error_handling: Whether and how to handle errors during iteration.","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_mapping.py#L474-L510","documentation":"StripErrorMetadata extracts the original failing element from an error output PCollection. It requires the input to be schema'd and contain one of the recognized error-record fields ('failed_row', 'element', 'record' per the source; the message text mentions 'msg'/'message'/'exception' variants). If neither holds, it raises this ValueError.","triggerScenarios":"Wiring StripErrorMetadata (or using with_error_handling workflows) to a PCollection that is not an error output — e.g. the main output of a transform, a custom error output with differently-named fields, or an untyped PCollection.","commonSituations":"Connecting to the wrong output name (main output instead of `<transform>.errors`), using a hand-rolled error output whose payload field is named something other than failed_row/element/record, or a runner/transform version whose error schema uses different field names.","solutions":["Point StripErrorMetadata's input at the transform's error output, e.g. `input: MyTransform.errors`, not the main output.","Ensure the upstream error output is schema'd and carries the failing element in a field named 'failed_row', 'element', or 'record'.","If using a custom error format, normalize it via MapToFields to produce one of the expected field names first."],"exampleFix":"# before\n- type: StripErrorMetadata\n  input: MyMapTransform   # main output, not errors\n# after\n- type: StripErrorMetadata\n  input: MyMapTransform.errors","handlingStrategy":"validation","validationCode":"from apache_beam.typehints import schema_from_element_type\nfields = {f.name for f in schema_from_element_type(pcoll.element_type).fields}\nassert fields & {'failed_row', 'element', 'record'}, 'not an error output pcoll'","typeGuard":"def is_error_output(pcoll) -> bool:\n    try:\n        names = {f.name for f in schema_from_element_type(pcoll.element_type).fields}\n    except TypeError:\n        return False\n    return bool(names & {'failed_row', 'element', 'record'})","tryCatchPattern":"try:\n    stripped = pcoll | StripErrorMetadata()\nexcept ValueError as e:\n    if 'does not appear to be an error output' in str(e):\n        raise ConfigError('wire StripErrorMetadata to <transform>.errors') from e","preventionTips":["Always reference the `.errors` output of the upstream transform","Keep error-output schemas to the built-in conventions (failed_row/element/record)","Inspect input schema before adding StripErrorMetadata"],"tags":["yaml","beam-yaml","schema","error-handling"],"backgroundTag":"unexpected-response-shape","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"}