{"record":{"id":"8b1f8c2539240bc5","repo":"microsoft/aspire","slug":"duplicate-step-name-step-name","errorCode":null,"errorMessage":"Duplicate step name: '{step.Name}'","messagePattern":"Duplicate step name: '(.+?)'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs","lineNumber":815,"sourceCode":"                Model = pipelineContext.Model\n            };\n\n            foreach (var callback in callbacks)\n            {\n                await callback(configContext).ConfigureAwait(false);\n            }\n        }\n    }\n\n    private static void ValidateSteps(IEnumerable<PipelineStep> steps)\n    {\n        var stepNames = new HashSet<string>(StringComparer.Ordinal);\n\n        foreach (var step in steps)\n        {\n            if (!stepNames.Add(step.Name))\n            {\n                throw new InvalidOperationException(\n                    $\"Duplicate step name: '{step.Name}'\");\n            }\n        }\n\n        foreach (var step in steps)\n        {\n            foreach (var dependency in step.DependsOnSteps)\n            {\n                if (!stepNames.Contains(dependency))\n                {\n                    throw new InvalidOperationException(\n                        $\"Step '{step.Name}' depends on unknown step '{dependency}'\");\n                }\n            }\n\n            foreach (var requiredBy in step.RequiredBySteps)\n            {\n                if (!stepNames.Contains(requiredBy))","sourceCodeStart":797,"sourceCodeEnd":833,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs#L797-L833","documentation":"The Aspire application model pipeline validates that every pipeline step has a unique name before executing. During ResolveStepsAsync, ValidateSteps adds each step name to an ordinal HashSet; a duplicate add means two steps registered with the same name, which would make dependency references ambiguous, so an InvalidOperationException is thrown before any step runs.","triggerScenarios":"Two or more IHostingPipelineStep implementations (or AddStep calls) registered with the identical Name string into the same DistributedApplicationPipeline; also occurs when an integration is added twice (e.g. two AddXxx calls each contributing a step with the same fixed name) or a step is registered per-resource with a constant name instead of including the resource name.","commonSituations":"Calling an integration extension method twice on the same builder when it unconditionally adds a fixed-name step; copying sample code that adds the same custom step twice; a loop over resources that registers a step named after the type rather than the resource; two different packages each contributing a step with a colliding name.","solutions":["Find the second registration of the step with the duplicated name and remove it or guard it so it runs only once","Make step names unique by incorporating the resource/identifier, e.g. $\"{resource.Name}-deploy\" instead of a constant","If an extension method may be called multiple times, have it check whether a step with that name already exists before adding","Update the dependency references (DependsOnSteps/RequiredBySteps) that pointed at the old shared name to point at the new unique names"],"exampleFix":"// before\nbuilder.Pipeline.AddStep(\"deploy\", ...);\nforeach (var r in resources) { builder.Pipeline.AddStep(\"deploy\", ...); }\n// after\nforeach (var r in resources) { builder.Pipeline.AddStep($\"deploy-{r.Name}\", ...); }","handlingStrategy":"validation","validationCode":"var names = new HashSet<string>(StringComparer.Ordinal);\nforeach (var step in pipeline.Steps)\n{\n    if (!names.Add(step.Name))\n        throw new InvalidOperationException($\"Duplicate step name registered: '{step.Name}'\");\n}","typeGuard":null,"tryCatchPattern":"try { await app.RunAsync(); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Duplicate step name:\"))\n{\n    // fix the duplicated step registration indicated in ex.Message\n}","preventionTips":["Generate step names from resource names ($\"{resource.Name}-{purpose}\") instead of constants","Before adding a step, check whether a step with the same name already exists and skip/reuse it","Keep step registration in one central place to avoid accidental double registration","Search your codebase for AddStep/DependsOn calls with the same literal name"],"tags":["pipeline","duplicate-name","validation","configuration"],"backgroundTag":"duplicate-step-name","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}