microsoft/semantic-kernel · error · KernelException
Unable to create gRPC request message for the '{operation.Na
Error message
Unable to create gRPC request message for the '{operation.Name}' gRPC operation. What it means
Thrown when `JsonSerializer.Deserialize(payload, type, ...)` returns null while building the gRPC request message. A null result means the JSON payload was valid JSON (`null` literal) or deserialized to a null reference of the contract type, so the runtime cannot proceed.
Source
Thrown at dotnet/src/Functions/Functions.Grpc/GrpcOperationRunner.cs:266
/// <summary>
/// Creates a gRPC operation request.
/// </summary>
/// <param name="operation">The gRPC operation.</param>
/// <param name="type">The operation request data type.</param>
/// <param name="arguments">The operation arguments.</param>
/// <returns>The operation request instance.</returns>
private object GenerateOperationRequest(GrpcOperation operation, Type type, Dictionary<string, string> arguments)
{
//Getting 'payload' argument to by used as gRPC request message
if (!arguments.TryGetValue(GrpcOperation.PayloadArgumentName, out string? payload) ||
string.IsNullOrEmpty(payload))
{
throw new KernelException($"No '{GrpcOperation.PayloadArgumentName}' argument representing gRPC request message is found for the '{operation.Name}' gRPC operation.");
}
//Deserializing JSON payload to gRPC request message
return JsonSerializer.Deserialize(payload!, type, s_propertyCaseInsensitiveOptions) ??
throw new KernelException($"Unable to create gRPC request message for the '{operation.Name}' gRPC operation.");
}
/// <summary>
/// Builds gRPC operation data contract type.
/// </summary>
/// <param name="dataContractMetadata">The data contract type metadata.</param>
/// <returns>.NET type representing the data contract type.</returns>
private static TypeInfo BuildGrpcOperationDataContractType(GrpcOperationDataContractType dataContractMetadata)
{
var assemblyName = new AssemblyName($"{dataContractMetadata.Name}Assembly");
var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
var moduleBuilder = assemblyBuilder.DefineDynamicModule($"{dataContractMetadata.Name}Module");
var typeBuilder = moduleBuilder.DefineType(dataContractMetadata.Name, TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.Class);
//Creating and adding a .NET property for each data contract filedView on GitHub (pinned to c028a0c7dc)
Solutions
- Ensure the payload is a non-null JSON object matching the operation's request contract.
- Validate the payload is not literally `null` before invoking.
- Log/inspect the payload string to confirm it carries the expected fields.
Example fix
// before
arguments["payload"] = "null";
// after
arguments["payload"] = "{\"id\":42,\"name\":\"x\"}"; Defensive patterns
Strategy: validation
Validate before calling
var p = arguments["payload"]?.ToString();
if (string.IsNullOrWhiteSpace(p) || p.Trim() == "null")
throw new InvalidOperationException("payload must be a non-null JSON object"); Prevention
- Serialize the request object rather than passing literal `null`.
- Validate the payload JSON shape against the contract before invoking.
When it happens
Trigger: Passing `payload = "null"`; a payload that deserializes to a nullable/null default for the dynamically built contract type.
Common situations: Upstream serializer emitted `null`; payload built from a nullable reference that was null; contract type mismatch causing a null instance.
Related errors
- Non-string gRPC operation arguments are not supported in Rel
- No '{GrpcOperation.PayloadArgumentName}' argument representi
- Unable to restore channel: invalid state.
- Unable to transform output to {typeof(TOutput)}.
- Unable to transform result into {typeof(TOutput).Name}
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/977000811eb9d6d4.
Report an issue: GitHub.