{"record":{"id":"7076a1acb33ead02","repo":"apache/beam","slug":"error-handling-output-error-output-cannot-be-among-the","errorCode":null,"errorMessage":"Error handling output \"{error_output}\" cannot be among the listed outputs {outputs}","messagePattern":"Error handling output \"(.+?)\" cannot be among the listed outputs (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_mapping.py","lineNumber":806,"sourceCode":"      error_handling: (Optional) Whether and how to handle errors during\n        partitioning.\n      language: The language of the `by` expression.\n  \"\"\"\n  split_fn = _as_callable_for_pcoll(pcoll, by, 'by', language)\n  try:\n    split_fn_output_type = trivial_inference.infer_return_type(\n        split_fn, [pcoll.element_type])\n  except (TypeError, ValueError):\n    pass\n  else:\n    if not typehints.is_consistent_with(split_fn_output_type,\n                                        typehints.Optional[str]):\n      raise ValueError(\n          f'Partition function \"{by}\" must return a string type '\n          f'not {split_fn_output_type}')\n  error_output = error_handling['output'] if error_handling else None\n  if error_output in outputs:\n    raise ValueError(\n        f'Error handling output \"{error_output}\" '\n        f'cannot be among the listed outputs {outputs}')\n  T = TypeVar('T')\n\n  def split(element):\n    tag = split_fn(element)\n    if tag is None:\n      tag = unknown_output\n    if not isinstance(tag, str):\n      raise ValueError(\n          f'Returned output name \"{tag}\" of type {type(tag)} '\n          f'from \"{by}\" must be a string.')\n    if tag not in outputs:\n      if unknown_output:\n        tag = unknown_output\n      else:\n        raise ValueError(f'Unknown output name \"{tag}\" from {by}')\n    return beam.pvalue.TaggedOutput(tag, element)","sourceCodeStart":788,"sourceCodeEnd":824,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_mapping.py#L788-L824","documentation":"The Partition transform reserves the error-handling output channel separately from the user's partition outputs. If the `error_handling.output` name (or None-derived default) collides with one of the listed `output` names, outputs would be ambiguous, so construction fails naming the conflicting output tag.","triggerScenarios":"Configuring a Partition transform with `error_handling: {output: bad}` where 'bad' is also listed among the transform's `output` names; `error_output in outputs` is true during validation in _Partition.","commonSituations":"Reusing the same tag name for both a valid partition and the error channel; copy-pasting output lists that already include an 'errors'/'invalid' tag while also enabling error_handling with that same name.","solutions":["Rename the error_handling output to a unique name not present in the outputs list (e.g. '_errors').","Remove the colliding name from the outputs list.","Disable error_handling if a reserved error output is not needed."],"exampleFix":"// before\noutputs: [small, large, errors]\nerror_handling: {output: errors, ...}\n// after\noutputs: [small, large]\nerror_handling: {output: _partition_errors, ...}\n","handlingStrategy":"validation","validationCode":"outputs = ['small', 'large']\nerror_output = error_handling['output'] if error_handling else None\nif error_output in outputs:\n    raise ValueError(f'Rename error output; {error_output!r} collides with partition outputs.')","typeGuard":null,"tryCatchPattern":"try:\n    partitioned = partition_transform.expand(pcoll)\nexcept ValueError as e:\n    if 'cannot be among the listed outputs' in str(e):\n        error_handling['output'] = error_handling['output'] + '_errors'\n    else:\n        raise","preventionTips":["Prefix error-handling output names (e.g. '_errors') so they never collide","Check outputs and error_handling.output for overlaps when generating configs programmatically","Validate transform configs (outputs disjointness) in CI before launch"],"tags":["apache-beam","yaml","partitioning","configuration"],"backgroundTag":"conflicting-config-options","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"}