microsoft/autogen · error · InvalidOperationException
Request is null.
Error message
Request is null.
What it means
GrpcAgentRuntime.HandleRequest throws InvalidOperationException when an incoming RpcRequest message is entirely null. The handler performs defensive validation on the gRPC wire payload before doing any work; a null request means the message envelope itself is malformed, which under protobuf normally indicates a protocol/version mismatch or a broken custom sender rather than an application bug.
Source
Thrown at dotnet/src/Microsoft.AutoGen/Core.Grpc/GrpcAgentRuntime.cs:146
};
return new CallOptions(headers: metadata);
}
}
private readonly bool _strictMessageDeserialization;
public IProtoSerializationRegistry SerializationRegistry { get; } = new ProtobufSerializationRegistry();
public void Dispose()
{
this._shutdownCts.Cancel();
this._messageRouter.Dispose();
}
private async ValueTask HandleRequest(RpcRequest request, CancellationToken cancellationToken = default)
{
if (request is null)
{
throw new InvalidOperationException("Request is null.");
}
if (request.Payload is null)
{
throw new InvalidOperationException("Payload is null.");
}
if (request.Target is null)
{
throw new InvalidOperationException("Target is null.");
}
var agentId = request.Target;
var agent = await this._agentsContainer.EnsureAgentAsync(agentId.FromProtobuf());
// Convert payload back to object
var payload = request.Payload;
var message = payload.ToObject(SerializationRegistry);
var messageContext = new MessageContext(request.RequestId, cancellationToken)View on GitHub (pinned to 027ecf0a37)
Solutions
- Align Microsoft.AutoGen package versions (and the embedded AgentRpc contract) across all processes in the deployment.
- If it reproduces, capture the raw gRPC frame/logging at the sender to find where the null envelope originates.
- In tests, pass a valid RpcRequest with Target and Payload set.
Example fix
// before (test double)
await runtime.HandleRequest(null); // throws
// after
var request = new RpcRequest { Target = agentId.ToProtobuf(), Payload = payload, RequestId = rid };
await runtime.HandleRequest(request); Defensive patterns
Strategy: validation
Validate before calling
if (request is null) { /* drop/log the malformed frame; never route null into the handler */ } Type guard
static bool IsValidRpcRequest(RpcRequest? r) => r is not null && r.Target is not null && r.Payload is not null;
Try / catch
try { await runtime.HandleRequest(request); }
catch (InvalidOperationException) { /* log the envelope, check proto version alignment */ } Prevention
- Pin identical Microsoft.AutoGen versions across all processes sharing the gRPC contract.
- Wrap router glue with null-envelope guards and metric counters to detect protocol drift early.
When it happens
Trigger: The runtime's message router delivers a null RpcRequest to HandleRequest — typically from deserialization edge cases, a client built against an incompatible proto contract, or internal code calling HandleRequest(null) directly (e.g. in tests).
Common situations: Version skew between the agent process and the runtime host (older/newer AgentRpc proto); custom test doubles that pass null; bugs in message-routing glue after a package upgrade.
Related errors
- Payload is null.
- Target is null.
- RequestId is null.
- CloudEvent is null.
- Request message is missing a target. Message: '{request}'.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/998c7ae90ec4ba51.
Report an issue: GitHub.