{"record":{"id":"387deb8c3b7e7d2a","repo":"apache/beam","slug":"duplicate-stage-name-uniquename-use-beam-withname-to-give","errorCode":null,"errorMessage":"Duplicate stage name: \"${uniqueName}\". Use beam.withName(...) to give your transform a unique name.","messagePattern":"Duplicate stage name: \"(.+?)\"\\. Use beam\\.withName\\(\\.\\.\\.\\) to give your transform a unique name\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/typescript/src/apache_beam/internal/pipeline.ts","lineNumber":159,"sourceCode":"    InputT extends pvalue.PValue<any>,\n    OutputT extends pvalue.PValue<any>,\n  >(transform: AsyncPTransformClass<InputT, OutputT>, input: InputT) {\n    const this_ = this;\n    const transformId = this.context.createUniqueName(\"transform\");\n    let parent: runnerApi.PTransform | undefined = undefined;\n    if (this.transformStack.length) {\n      parent =\n        this.proto!.components!.transforms![\n          this.transformStack[this.transformStack.length - 1]\n        ];\n      parent.subtransforms.push(transformId);\n    } else {\n      this.proto.rootTransformIds.push(transformId);\n    }\n    const uniqueName =\n      (parent ? parent.uniqueName + \"/\" : \"\") + extractName(transform);\n    if (this.usedStageNames.has(uniqueName)) {\n      throw new Error(\n        `Duplicate stage name: \"${uniqueName}\". ` +\n          \"Use beam.withName(...) to give your transform a unique name.\",\n      );\n    }\n    this.usedStageNames.add(uniqueName);\n    const transformProto: runnerApi.PTransform = {\n      uniqueName,\n      subtransforms: [],\n      inputs: objectMap(pvalue.flattenPValue(input), (pc) => pc.getId()),\n      outputs: {},\n      environmentId: this.defaultEnvironment,\n      displayData: [],\n      annotations: {},\n    };\n    this.proto.components!.transforms![transformId] = transformProto;\n    return { id: transformId, proto: transformProto };\n  }\n","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/typescript/src/apache_beam/internal/pipeline.ts#L141-L177","documentation":"preApplyTransform detected that a transform's stage name collides with an already-registered unique name. Beam derives stage names from transform names, and the runner keyed this pipeline's stage by that name; the duplicate is the transform being applied without an explicit distinct name.","triggerScenarios":"Thrown at sdks/typescript/src/apache_beam/internal/pipeline.ts:159 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wrap the colliding transform in beam.withName('someUniqueName', ...) as the message suggests.","Apply the same composite transform multiple times only via a loop variable or counter appended to withName so each application gets a distinct name.","If names come from user config, sanitize/deduplicate them before applying transforms."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}