microsoft/aspire · error · InvalidOperationException
Step ' ' not found for task
Error message
Step '{stepId}' not found for task '{activity.Data.Id}' What it means
While rendering pipeline progress, the CLI receives a task activity from the AppHost backchannel and looks up its parent step by activity.Data.StepId in the known steps dictionary. If the step id is absent the CLI's internal model is inconsistent with what the AppHost emitted, so it throws this InvalidOperationException as an internal invariant failure.
Solutions
- Update CLI and Aspire.Hosting packages to matching versions and retry the command
- Re-run the publish/pipeline command — if reproducible, file an issue with the AppHost's pipeline definition
- Check whether the AppHost emits activities for steps outside the requested targetStep graph
Defensive patterns
Strategy: try-catch
Validate before calling
if (steps is not null && activity.Data.StepId is string sid && !steps.ContainsKey(sid))
{
// log and skip the activity instead of crashing
} Try / catch
try { RenderTaskActivity(activity); }
catch (InvalidOperationException ex) when (ex.Message.Contains("not found for task")) { log.LogWarning(ex.Message); } Prevention
- Keep CLI and AppHost versions in sync
- Don't emit activities for steps outside the enumerated pipeline
- Report persistent repros to Aspire with the pipeline definition
When it happens
Trigger: An AppHost sends a task activity whose StepId does not match any step returned by GetPipelineStepsAsync / tracked in the local steps map — e.g. a step that was filtered out by targetStep or a newer AppHost emitting task ids the CLI didn't record.
Common situations: Mixed CLI/AppHost versions during `aspire publish` or `aspire run --publisher`; a custom pipeline step emitted by the AppHost that the CLI's step enumeration skipped; race between capability/step listing and activity streaming.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Run completed without returning a backchannel.
- Step ' ' not found in pipeline. Available steps
- The AppHost does not support --list-steps. Update the…
- A step with the name
- Already connected to AppHost backchannel.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/4680b42b2ff9f9ae.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Cli/Commands/PipelineCommandBase.cs:913
case LogLevel.Debug:
case LogLevel.Trace:
logger.Info(stepInfo.Id, prefixedMessage, dim: true);
break;
case LogLevel.Information:
default:
logger.Info(stepInfo.Id, prefixedMessage);
break;
}
}
}
else
{
var stepId = activity.Data.StepId;
Debug.Assert(stepId != null, "Activity data should have a StepId for task activities.");
if (!steps.TryGetValue(stepId, out var stepInfo))
{
throw new InvalidOperationException($"Step '{stepId}' not found for task '{activity.Data.Id}'");
}
var tasks = stepInfo.Tasks;
if (!tasks.TryGetValue(activity.Data.Id, out var task))
{
var statusText = ConvertTextWithMarkdownFlag(activity.Data.StatusText, activity.Data);
task = new TaskInfo
{
Id = activity.Data.Id,
StatusText = statusText,
StartTime = DateTime.UtcNow,
CompletionState = activity.Data.CompletionState
};
tasks[activity.Data.Id] = task;
logger.Progress(stepInfo.Id, statusText);
}View on GitHub (pinned to 25830f84bd)