{"record":{"id":"4680b42b2ff9f9ae","repo":"microsoft/aspire","slug":"step-stepid-not-found-for-task-activity-data-id","errorCode":null,"errorMessage":"Step '{stepId}' not found for task '{activity.Data.Id}'","messagePattern":"Step '(.+?)' not found for task '(.+?)'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Commands/PipelineCommandBase.cs","lineNumber":913,"sourceCode":"                            case LogLevel.Debug:\n                            case LogLevel.Trace:\n                                logger.Info(stepInfo.Id, prefixedMessage, dim: true);\n                                break;\n                            case LogLevel.Information:\n                            default:\n                                logger.Info(stepInfo.Id, prefixedMessage);\n                                break;\n                        }\n                    }\n                }\n                else\n                {\n                    var stepId = activity.Data.StepId;\n                    Debug.Assert(stepId != null, \"Activity data should have a StepId for task activities.\");\n\n                    if (!steps.TryGetValue(stepId, out var stepInfo))\n                    {\n                        throw new InvalidOperationException($\"Step '{stepId}' not found for task '{activity.Data.Id}'\");\n                    }\n\n                    var tasks = stepInfo.Tasks;\n\n                    if (!tasks.TryGetValue(activity.Data.Id, out var task))\n                    {\n                        var statusText = ConvertTextWithMarkdownFlag(activity.Data.StatusText, activity.Data);\n                        task = new TaskInfo\n                        {\n                            Id = activity.Data.Id,\n                            StatusText = statusText,\n                            StartTime = DateTime.UtcNow,\n                            CompletionState = activity.Data.CompletionState\n                        };\n\n                        tasks[activity.Data.Id] = task;\n                        logger.Progress(stepInfo.Id, statusText);\n                    }","sourceCodeStart":895,"sourceCodeEnd":931,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Commands/PipelineCommandBase.cs#L895-L931","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (steps is not null && activity.Data.StepId is string sid && !steps.ContainsKey(sid))\n{\n    // log and skip the activity instead of crashing\n}","typeGuard":null,"tryCatchPattern":"try { RenderTaskActivity(activity); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"not found for task\")) { log.LogWarning(ex.Message); }","preventionTips":["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"],"tags":["cli","pipeline","internal-state"],"backgroundTag":"internal-invariant-violation","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"}