microsoft/aspire · error · InvalidOperationException

Parent step with ID ' ' does not exist.

Error message

Parent step with ID '{task.StepId}' does not exist.

What it means

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.

Solutions

  1. Update the task via the same reporter that created it (task's owning reporter / context.ReportingStep pipeline).
  2. Keep task references scoped to the current activity; create a new step/task for a new run.
  3. Verify no code removes or resets steps before pending task updates complete.
  4. In tests, use a single shared reporter instance for step and task operations.

Example fix

// before
await oldReporter.UpdateTaskAsync(task, newText, false);
// after
await task.Reporter.UpdateTaskAsync(task, newText, false);
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

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."); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/ab14f4bc7a8fbf9d. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting/Pipelines/PipelineActivityReporter.cs:146

            step.CompletionState = completionState;
            step.CompletionText = completionText;
        }

        var state = new PublishingActivity
        {
            Type = PublishingActivityTypes.Step,
            Data = CreateStepActivityData(step, completionText, completionState, enableMarkdown)
        };

        await ActivityItemUpdated.Writer.WriteAsync(state, cancellationToken).ConfigureAwait(false);
    }

    public async Task UpdateTaskAsync(ReportingTask task, string statusText, bool enableMarkdown, CancellationToken cancellationToken)
    {
        if (!_steps.TryGetValue(task.StepId, out var parentStep))
        {
            throw new InvalidOperationException($"Parent step with ID '{task.StepId}' does not exist.");
        }

        lock (parentStep)
        {
            if (parentStep.CompletionState != CompletionState.InProgress)
            {
                throw new InvalidOperationException($"Cannot update task '{task.Id}' because its parent step '{task.StepId}' is already complete.");
            }

            task.StatusText = statusText;
        }

        var state = new PublishingActivity
        {
            Type = PublishingActivityTypes.Task,
            Data = new PublishingActivityData
            {
                Id = task.Id,

View on GitHub (pinned to 25830f84bd)