{"record":{"id":"9d7dabbc69073c3d","repo":"microsoft/aspire","slug":"step-with-id-step-id-does-not-exist","errorCode":null,"errorMessage":"Step with ID '{step.Id}' does not exist.","messagePattern":"Step with ID '(.+?)' does not exist\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Pipelines/PipelineActivityReporter.cs","lineNumber":86,"sourceCode":"        var step = new ReportingStep(this, Guid.NewGuid().ToString(), title, resolvedParentStepId, hierarchyLevel);\n        _steps.TryAdd(step.Id, step);\n        _stepIdsByTitle[title] = step.Id;\n\n        var state = new PublishingActivity\n        {\n            Type = PublishingActivityTypes.Step,\n            Data = CreateStepActivityData(step, step.Title, CompletionState.InProgress, enableMarkdown: false)\n        };\n\n        await ActivityItemUpdated.Writer.WriteAsync(state, cancellationToken).ConfigureAwait(false);\n        return step;\n    }\n\n    public async Task<ReportingTask> CreateTaskAsync(ReportingStep step, string statusText, bool enableMarkdown, CancellationToken cancellationToken)\n    {\n        if (!_steps.TryGetValue(step.Id, out var parentStep))\n        {\n            throw new InvalidOperationException($\"Step with ID '{step.Id}' does not exist.\");\n        }\n\n        lock (parentStep)\n        {\n            if (parentStep.CompletionState != CompletionState.InProgress)\n            {\n                throw new InvalidOperationException($\"Cannot create task for step '{step.Id}' because the step is already complete.\");\n            }\n        }\n\n        var task = new ReportingTask(Guid.NewGuid().ToString(), step.Id, statusText, parentStep);\n\n        // Add task to parent step\n        parentStep.AddTask(task);\n\n        var state = new PublishingActivity\n        {\n            Type = PublishingActivityTypes.Task,","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Pipelines/PipelineActivityReporter.cs#L68-L104","documentation":"PipelineActivityReporter.CreateTaskAsync creates a child ReportingTask under an existing ReportingStep. It looks the step up by ID in the reporter's internal step dictionary; if the ID is absent the step was never registered with this reporter (or was already removed), so an InvalidOperationException is thrown rather than silently attaching a task to nothing.","triggerScenarios":"Calling reporter.CreateTaskAsync(step, ...) with a ReportingStep instance whose Id was never passed to this reporter (e.g. a step created by a different PipelineActivityReporter instance, or after the step's parent pipeline context was torn down).","commonSituations":"Sharing a ReportingStep across two reporters in tests, calling CreateTaskAsync after the deployment/publish activity completed and steps were cleared, or constructing a step manually instead of receiving it from PipelineStepContext.","solutions":["Create the task via the same reporter that owns the step (e.g. context.ReportingStep.CreateTaskAsync inside the pipeline step).","Verify the step was registered first (CreateStepAsync on the same reporter) before creating tasks under it.","In tests, use one reporter instance for both the step creation and task creation.","Check lifecycle ordering: do not create tasks after the activity has completed/cleared steps."],"exampleFix":"// before\nawait wrongReporter.CreateTaskAsync(step, text, false);\n// after\nawait step.Reporter.CreateTaskAsync(step, text, false);","handlingStrategy":"try-catch","validationCode":"if (!reporterOwnsStep) throw new InvalidOperationException(\"Step not registered with this reporter.\");","typeGuard":"null","tryCatchPattern":"try { await reporter.CreateTaskAsync(step, text, false); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"does not exist\")) { logger.LogWarning(ex, \"Skipping task creation: step not registered.\"); }","preventionTips":["Always create tasks via the same reporter/context that owns the step","Never share ReportingStep instances across reporters","Create tasks during the step's active lifetime only","In tests, register steps with the reporter under test before creating tasks"],"tags":["reporting","lifecycle","invalid-state"],"backgroundTag":"resource-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}