{"record":{"id":"977000811eb9d6d4","repo":"microsoft/semantic-kernel","slug":"unable-to-create-grpc-request-message-for-the-op","errorCode":null,"errorMessage":"Unable to create gRPC request message for the '{operation.Name}' gRPC operation.","messagePattern":"Unable to create gRPC request message for the '(.+?)' gRPC operation\\.","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Functions/Functions.Grpc/GrpcOperationRunner.cs","lineNumber":266,"sourceCode":"    /// <summary>\n    /// Creates a gRPC operation request.\n    /// </summary>\n    /// <param name=\"operation\">The gRPC operation.</param>\n    /// <param name=\"type\">The operation request data type.</param>\n    /// <param name=\"arguments\">The operation arguments.</param>\n    /// <returns>The operation request instance.</returns>\n    private object GenerateOperationRequest(GrpcOperation operation, Type type, Dictionary<string, string> arguments)\n    {\n        //Getting 'payload' argument to by used as gRPC request message\n        if (!arguments.TryGetValue(GrpcOperation.PayloadArgumentName, out string? payload) ||\n            string.IsNullOrEmpty(payload))\n        {\n            throw new KernelException($\"No '{GrpcOperation.PayloadArgumentName}' argument representing gRPC request message is found for the '{operation.Name}' gRPC operation.\");\n        }\n\n        //Deserializing JSON payload to gRPC request message\n        return JsonSerializer.Deserialize(payload!, type, s_propertyCaseInsensitiveOptions) ??\n            throw new KernelException($\"Unable to create gRPC request message for the '{operation.Name}' gRPC operation.\");\n    }\n\n    /// <summary>\n    /// Builds gRPC operation data contract type.\n    /// </summary>\n    /// <param name=\"dataContractMetadata\">The data contract type metadata.</param>\n    /// <returns>.NET type representing the data contract type.</returns>\n    private static TypeInfo BuildGrpcOperationDataContractType(GrpcOperationDataContractType dataContractMetadata)\n    {\n        var assemblyName = new AssemblyName($\"{dataContractMetadata.Name}Assembly\");\n\n        var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);\n\n        var moduleBuilder = assemblyBuilder.DefineDynamicModule($\"{dataContractMetadata.Name}Module\");\n\n        var typeBuilder = moduleBuilder.DefineType(dataContractMetadata.Name, TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.Class);\n\n        //Creating and adding a .NET property for each data contract filed","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Functions/Functions.Grpc/GrpcOperationRunner.cs#L248-L284","documentation":"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.","triggerScenarios":"Passing `payload = \"null\"`; a payload that deserializes to a nullable/null default for the dynamically built contract type.","commonSituations":"Upstream serializer emitted `null`; payload built from a nullable reference that was null; contract type mismatch causing a null instance.","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."],"exampleFix":"// before\narguments[\"payload\"] = \"null\";\n// after\narguments[\"payload\"] = \"{\\\"id\\\":42,\\\"name\\\":\\\"x\\\"}\";","handlingStrategy":"validation","validationCode":"var p = arguments[\"payload\"]?.ToString();\nif (string.IsNullOrWhiteSpace(p) || p.Trim() == \"null\")\n    throw new InvalidOperationException(\"payload must be a non-null JSON object\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Serialize the request object rather than passing literal `null`.","Validate the payload JSON shape against the contract before invoking."],"tags":["grpc","serialization","arguments"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}