{"record":{"id":"9c6eccaa81b3f4f6","repo":"apache/beam","slug":"main-output-tag-r-must-be-different-from-side-output-tags-r","errorCode":null,"errorMessage":"Main output tag %r must be different from side output tags %r.","messagePattern":"Main output tag %r must be different from side output tags %r\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/core.py","lineNumber":1837,"sourceCode":"        be used for the main output (which will not have a tag associated with\n        it).\n\n    Returns:\n      ~apache_beam.pvalue.DoOutputsTuple: An object of type\n      :class:`~apache_beam.pvalue.DoOutputsTuple` that bundles together all\n      the outputs of a :class:`ParDo` transform and allows accessing the\n      individual :class:`~apache_beam.pvalue.PCollection` s for each output\n      using an ``object.tag`` syntax.\n\n    Raises:\n      TypeError: if the **self** object is not a\n        :class:`~apache_beam.pvalue.PCollection` that is the result of a\n        :class:`ParDo` transform.\n      ValueError: if **main_kw** contains any key other than\n        ``'main'``.\n    \"\"\"\n    if main in tags:\n      raise ValueError(\n          'Main output tag %r must be different from side output tags %r.' %\n          (main, tags))\n    type_hints = self.get_type_hints()\n    declared_tags = set(type_hints.tagged_output_types().keys())\n    requested_tags = set(tags)\n\n    unknown = requested_tags - declared_tags\n    if unknown and declared_tags:  # Only warn if type hints exist\n      logging.warning(\n          \"Tags %s requested in with_outputs() but not declared \"\n          \"in type hints. Declared tags: %s\",\n          unknown,\n          declared_tags)\n    return _MultiParDo(self, tags, main, allow_unknown_tags)\n\n  def _do_fn_info(self):\n    return DoFnInfo.create(self.fn, self.args, self.kwargs)\n","sourceCodeStart":1819,"sourceCodeEnd":1855,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/core.py#L1819-L1855","documentation":"When a ParDo declares multiple outputs, each output is identified by a tag. The main output tag and side output tags must be distinct namespaces; Beam raises this ValueError at transform validation time if the requested main tag collides with one of the side output tags.","triggerScenarios":"Calling pardo.with_outputs('main', *side_tags) or with_outputs(tag, main='tag') where the main tag string is also present in the side output tags tuple.","commonSituations":"Copy-paste of tag strings; defaulting main='main' while also passing 'main' as a side tag; dynamically built tag lists that accidentally include the main tag.","solutions":["Rename the colliding side output tag so it differs from the main tag.","Explicitly choose a distinct main tag, e.g. with_outputs('side1', main='primary').","Deduplicate/validate the tag list programmatically before calling with_outputs (set difference between tags and main)."],"exampleFix":"// before\npardo.with_outputs('main', 'main', 'other')\n// after\npardo.with_outputs('main', 'side_main', 'other')","handlingStrategy":"validation","validationCode":"tags = ['side1', 'side2']\nmain = 'main'\nassert main not in tags, f'main tag {main!r} collides with side tags {tags}'","typeGuard":"def tags_are_disjoint(main, tags):\n    return main not in tags","tryCatchPattern":"try:\n    pardo = pardo.with_outputs(*tags, main=main)\nexcept ValueError as e:\n    logger.error('Output tag collision: %s', e)\n    raise","preventionTips":["Keep output tag names in module-level constants with a naming convention (e.g. side_ prefix).","Deduplicate tag lists before calling with_outputs.","Never use the default 'main' string as a side output tag."],"tags":["python","apache-beam","pardo","output-tags"],"backgroundTag":"invalid-argument-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"}