microsoft/semantic-kernel · error · InvalidOperationException
Failed to start process
Error message
Failed to start process
What it means
Thrown by `DaprTestProcessContext.StartWithEventAsync` when the HTTP POST that starts the process on the Dapr test host (port 5200) returns a non-success status code. The exception carries no body/detail, so the underlying failure (validation error, host error, transport issue) must be inferred from logs. It is an InvalidOperationException.
Source
Thrown at dotnet/src/Experimental/Process.IntegrationTestRunner.Dapr/DaprTestProcessContext.cs:50
TypeInfoResolver = new ProcessStateTypeResolver<KickoffStep>(),
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
}
/// <summary>
/// Starts the process with an initial event.
/// </summary>
/// <param name="initialEvent">The initial event.</param>
/// <returns></returns>
internal async Task StartWithEventAsync(KernelProcessEvent initialEvent)
{
var daprProcess = DaprProcessInfo.FromKernelProcess(this._process);
var request = new ProcessStartRequest { Process = daprProcess, InitialEvent = initialEvent.ToJson() };
var response = await this._httpClient.PostAsJsonAsync($"http://localhost:5200/processes/{this._processId}", request, options: this._serializerOptions).ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
{
throw new InvalidOperationException("Failed to start process");
}
}
public override async Task<KernelProcess> GetStateAsync()
{
var response = await this._httpClient.GetFromJsonAsync<DaprProcessInfo>($"http://localhost:5200/processes/{this._processId}", options: this._serializerOptions);
return response switch
{
null => throw new InvalidOperationException("Process not found"),
_ => response.ToKernelProcess()
};
}
public override Task SendEventAsync(KernelProcessEvent processEvent)
{
throw new NotImplementedException();
}
View on GitHub (pinned to c028a0c7dc)
Solutions
- Check the Dapr test host logs for the actual error behind the non-success status code.
- Verify `localhost:5200` is the Dapr process host (not another service) and that it is the expected version.
- Inspect the serialized `ProcessStartRequest` JSON for null/malformed `Process` or `InitialEvent`.
- Confirm the process object is valid (non-null Id, resolvable steps) before posting.
Example fix
// before
var response = await this._httpClient.PostAsJsonAsync(url, request);
response.EnsureSuccessStatusCode(); // opaque
// after (surface the body for diagnosis)
var response = await this._httpClient.PostAsJsonAsync(url, request);
if (!response.IsSuccessStatusCode)
{
var body = await response.Content.ReadAsStringAsync();
throw new InvalidOperationException($"Failed to start process: {(int)response.StatusCode} {response.StatusCode}: {body}");
} Defensive patterns
Strategy: retry
Validate before calling
if (string.IsNullOrWhiteSpace(process?.State?.Id))
throw new InvalidOperationException("Cannot start a process with no Id via Dapr.");
var request = new ProcessStartRequest { Process = DaprProcessInfo.FromKernelProcess(process), InitialEvent = initialEvent.ToJson() };
if (string.IsNullOrWhiteSpace(request.InitialEvent))
throw new InvalidOperationException("InitialEvent serialized to null; check initialEvent payload."); Type guard
bool IsStartable(KernelProcess p, KernelProcessEvent e) =>
!string.IsNullOrWhiteSpace(p?.State?.Id) && e is not null; Try / catch
try { await context.StartWithEventAsync(initialEvent); }
catch (InvalidOperationException ex) when (ex.Message == "Failed to start process")
{
var body = await lastResponse.Content.ReadAsStringAsync();
_logger.LogError("Dapr start failed: {Body}", body);
throw;
} Prevention
- Confirm the Dapr test host is the service on port 5200 before running.
- Log the response body/status on failure to avoid the opaque message.
- Validate the process and initial event payloads before posting.
When it happens
Trigger: POST to `http://localhost:5200/processes/{id}` with a start request whose `Process` or `InitialEvent` is malformed/rejected by the host; the Dapr test host is up but returns 4xx/5xx; the process payload references unknown steps.
Common situations: Dapr runtime/test host running but misconfigured; process serialization mismatch between client and host versions; initial event payload schema mismatch; port conflict putting a different service on 5200.
Related errors
- Process not found
- Dapr Test Host did not start
- This method is not implemented in this test fixture.
- The Map must be initialized before accessing the Name proper
- The process cannot be started before it has been initialized
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/0f882569e552fefe.
Report an issue: GitHub.