{"record":{"id":"8b94fbb6a749b2e9","repo":"microsoft/autogen","slug":"protodata-is-null","errorCode":null,"errorMessage":"ProtoData is null.","messagePattern":"ProtoData is null\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Microsoft.AutoGen/Core.Grpc/GrpcAgentRuntime.cs","lineNumber":222,"sourceCode":"        }\n\n        if (_pendingRequests.TryRemove(request.RequestId, out var resultSink))\n        {\n            var payload = request.Payload;\n            var message = payload.ToObject(SerializationRegistry);\n            resultSink.SetResult(message);\n        }\n    }\n\n    private async ValueTask HandlePublish(CloudEvent evt, CancellationToken cancellationToken = default)\n    {\n        if (evt is null)\n        {\n            throw new InvalidOperationException(\"CloudEvent is null.\");\n        }\n        if (evt.ProtoData is null)\n        {\n            throw new InvalidOperationException(\"ProtoData is null.\");\n        }\n        if (evt.Attributes is null)\n        {\n            throw new InvalidOperationException(\"Attributes is null.\");\n        }\n\n        var topic = new TopicId(evt.Type, evt.Source);\n        Contracts.AgentId? sender = null;\n        if (evt.Attributes.TryGetValue(Constants.AGENT_SENDER_TYPE_ATTR, out var typeValue) && evt.Attributes.TryGetValue(Constants.AGENT_SENDER_KEY_ATTR, out var keyValue))\n        {\n            sender = new Contracts.AgentId\n            {\n                Type = typeValue.CeString,\n                Key = keyValue.CeString\n            };\n        }\n\n        var messageId = evt.Id;","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/Microsoft.AutoGen/Core.Grpc/GrpcAgentRuntime.cs#L204-L240","documentation":"Thrown by GrpcAgentRuntime.HandlePublish when an incoming CloudEvent has a null ProtoData field. The runtime requires every published CloudEvent to carry its payload as protobuf-packed Any data (evt.ProtoData), which it later deserializes with a registered serializer. A null ProtoData means the event was published without a payload, so the runtime cannot route a deserializable message to agents.","triggerScenarios":"Calling the gRPC publish path (PublishMessageAsync on the grpc runtime, or a client sending a CloudEvent with only attributes set) with a null or unset data_protobuf field; a custom sender building a CloudEvent manually via new CloudEvent { Type = ..., Source = ... } and omitting ProtoData.","commonSituations":"Custom gateways or test harnesses that construct CloudEvent messages by hand; interop with non-.NET clients that publish CloudEvents without protobuf payloads; upgrades where the payload packing moved from a different field to ProtoData.","solutions":["Ensure the message you publish is serialized and assigned to the CloudEvent's ProtoData (Any.Pack(protoMessage)) before sending","If publishing from agent code, use the runtime's PublishMessageAsync API instead of hand-building CloudEvent instances, so the serializer registry packs the payload for you","Verify the client library version matches the runtime version so it populates data_protobuf rather than a legacy payload field"],"exampleFix":"// before\nvar evt = new CloudEvent { Type = topic.Type, Source = topic.Source }; // no payload\nawait runtime.PublishMessageAsync(evt);\n\n// after\nvar evt = new CloudEvent\n{\n    Type = topic.Type,\n    Source = topic.Source,\n    ProtoData = Any.Pack(myProtoMessage)\n};","handlingStrategy":"validation","validationCode":"bool CanHandle(CloudEvent evt) => evt is not null && evt.ProtoData is not null;","typeGuard":"static bool HasProtoPayload(CloudEvent evt) => evt?.ProtoData is not null;","tryCatchPattern":"try { await runtime.OnMessageAsync(msg); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"ProtoData\")) { _logger.LogWarning(ex, \"Dropping CloudEvent without payload: {Type}/{Source}\", evt.Type, evt.Source); }","preventionTips":["Always publish through runtime APIs that pack ProtoData for you","Validate inbound CloudEvents at the gateway (null checks on ProtoData/Attributes) before forwarding"],"tags":["grpc","cloudevent","serialization","null-check"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}