{"record":{"id":"ab14f4bc7a8fbf9d","repo":"microsoft/aspire","slug":"parent-step-with-id-task-stepid-does-not-exist","errorCode":null,"errorMessage":"Parent step with ID '{task.StepId}' does not exist.","messagePattern":"Parent step with ID '(.+?)' does not exist\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Pipelines/PipelineActivityReporter.cs","lineNumber":146,"sourceCode":"\n            step.CompletionState = completionState;\n            step.CompletionText = completionText;\n        }\n\n        var state = new PublishingActivity\n        {\n            Type = PublishingActivityTypes.Step,\n            Data = CreateStepActivityData(step, completionText, completionState, enableMarkdown)\n        };\n\n        await ActivityItemUpdated.Writer.WriteAsync(state, cancellationToken).ConfigureAwait(false);\n    }\n\n    public async Task UpdateTaskAsync(ReportingTask task, string statusText, bool enableMarkdown, CancellationToken cancellationToken)\n    {\n        if (!_steps.TryGetValue(task.StepId, out var parentStep))\n        {\n            throw new InvalidOperationException($\"Parent step with ID '{task.StepId}' does not exist.\");\n        }\n\n        lock (parentStep)\n        {\n            if (parentStep.CompletionState != CompletionState.InProgress)\n            {\n                throw new InvalidOperationException($\"Cannot update task '{task.Id}' because its parent step '{task.StepId}' is already complete.\");\n            }\n\n            task.StatusText = statusText;\n        }\n\n        var state = new PublishingActivity\n        {\n            Type = PublishingActivityTypes.Task,\n            Data = new PublishingActivityData\n            {\n                Id = task.Id,","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Pipelines/PipelineActivityReporter.cs#L128-L164","documentation":"UpdateTaskAsync looks up the task's parent step by task.StepId in the reporter's step dictionary before mutating the task. If the step is not found, the step was never registered with this reporter or has been removed, and an InvalidOperationException is thrown instead of updating an orphaned task.","triggerScenarios":"Calling reporter.UpdateTaskAsync(task, ...) when the task's parent step was created by a different reporter, or after the reporter's steps were cleared at activity completion.","commonSituations":"Cross-reporter usage in tests, updating a task retained from a previous publish/deploy run, or holding a ReportingTask beyond the lifetime of its PipelineActivityReporter.","solutions":["Update the task via the same reporter that created it (task's owning reporter / context.ReportingStep pipeline).","Keep task references scoped to the current activity; create a new step/task for a new run.","Verify no code removes or resets steps before pending task updates complete.","In tests, use a single shared reporter instance for step and task operations."],"exampleFix":"// before\nawait oldReporter.UpdateTaskAsync(task, newText, false);\n// after\nawait task.Reporter.UpdateTaskAsync(task, newText, false);","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { await reporter.UpdateTaskAsync(task, text, false); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"does not exist\")) { logger.LogDebug(\"Parent step gone; dropping task update.\"); }","preventionTips":["Keep ReportingTask references scoped to the reporter that created them","Do not cache tasks across publish/deploy runs","Dispose/abandon tasks when the activity completes","In tests, use a single reporter for all step/task operations"],"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"}