microsoft/aspire · error · InvalidOperationException

Cannot create task: Reporter is not set.

Error message

Cannot create task: Reporter is not set.

What it means

ReportingStep.CreateTaskAsync(string, CancellationToken) throws InvalidOperationException when the step's Reporter property has not been set. The step delegates task creation to its IStepReporter; without a reporter there is nowhere to create the task. This is a configuration/lifecycle error — the step must be initialized with a reporter before use.

Solutions

  1. Ensure the ReportingStep is created/obtained through the pipeline execution infrastructure so Reporter is attached.
  2. Assign a valid IStepReporter (or equivalent) to the step's Reporter property before calling CreateTaskAsync.
  3. In tests, supply a test/fake reporter instead of using a bare step.
  4. Check for null with the pattern below before calling CreateTaskAsync.

Example fix

// before
var task = await step.CreateTaskAsync("Building image...");

// after
if (step.Reporter is null)
{
    throw new InvalidOperationException("Attach a reporter to the step before creating tasks.");
}
var task = await step.CreateTaskAsync("Building image...");
Defensive patterns

Strategy: type-guard

Validate before calling

if (step.Reporter is null)
{
    throw new InvalidOperationException("Step has no reporter; create it via the pipeline API.");
}

Type guard

bool canCreateTask = step.Reporter is not null;

Try / catch

try
{
    var task = await step.CreateTaskAsync(statusText);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Reporter is not set"))
{
    logger.LogError(ex, "ReportingStep used without a reporter; use the pipeline API to create steps.");
}

Prevention

When it happens

Trigger: Calling await step.CreateTaskAsync("status") on a ReportingStep that was obtained or constructed without its Reporter being assigned (e.g. used outside the normal pipeline execution flow, or before the pipeline attaches its reporter).

Common situations: Custom pipeline code grabbing a ReportingStep and creating tasks directly, unit tests constructing ReportingStep manually, or code running after the pipeline context has disposed/reset the reporter.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


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

Appendix: source

Thrown at src/Aspire.Hosting/Pipelines/ReportingStep.cs:110

        }

        var maxState = CompletionState.InProgress;
        foreach (var task in _tasks.Values)
        {
            if ((int)task.CompletionState > (int)maxState)
            {
                maxState = task.CompletionState;
            }
        }
        return maxState;
    }

    /// <inheritdoc />
    public async Task<IReportingTask> CreateTaskAsync(string statusText, CancellationToken cancellationToken = default)
    {
        if (Reporter is null)
        {
            throw new InvalidOperationException("Cannot create task: Reporter is not set.");
        }

        return await Reporter.CreateTaskAsync(this, statusText, enableMarkdown: false, cancellationToken: cancellationToken).ConfigureAwait(false);
    }

    /// <inheritdoc />
    public async Task<IReportingTask> CreateTaskAsync(MarkdownString statusText, CancellationToken cancellationToken = default)
    {
        ArgumentNullException.ThrowIfNull(statusText);

        if (Reporter is null)
        {
            throw new InvalidOperationException("Cannot create task: Reporter is not set.");
        }

        return await Reporter.CreateTaskAsync(this, statusText.Value, enableMarkdown: true, cancellationToken: cancellationToken).ConfigureAwait(false);
    }

View on GitHub (pinned to 25830f84bd)