{"record":{"id":"7f65c301248dc761","repo":"microsoft/autogen","slug":"invalid-subscription-message","errorCode":null,"errorMessage":"Invalid subscription message.","messagePattern":"Invalid subscription message\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_utils.py","lineNumber":45,"sourceCode":"    oneofcase = subscription.WhichOneof(\"subscription\")\n    match oneofcase:\n        case \"typeSubscription\":\n            type_subscription_msg: agent_worker_pb2.TypeSubscription = subscription.typeSubscription\n            return TypeSubscription(\n                topic_type=type_subscription_msg.topic_type,\n                agent_type=type_subscription_msg.agent_type,\n                id=subscription.id,\n            )\n\n        case \"typePrefixSubscription\":\n            type_prefix_subscription_msg: agent_worker_pb2.TypePrefixSubscription = subscription.typePrefixSubscription\n            return TypePrefixSubscription(\n                topic_type_prefix=type_prefix_subscription_msg.topic_type_prefix,\n                agent_type=type_prefix_subscription_msg.agent_type,\n                id=subscription.id,\n            )\n        case None:\n            raise ValueError(\"Invalid subscription message.\")\n","sourceCodeStart":27,"sourceCodeEnd":46,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_utils.py#L27-L46","documentation":"subscription_from_proto converts an incoming protobuf Subscription message back into an AutoGen Subscription by inspecting the `subscription` oneof field. If the oneof is unset (None), the message is malformed and the function raises ValueError('Invalid subscription message.') rather than guessing a type.","triggerScenarios":"The gRPC host (or another worker) sends an agent_worker_pb2.Subscription whose `subscription` oneof is not populated — e.g. hand-crafted protos, a mismatched proto schema between host and worker, or memory corruption of the message — and this worker tries to deserialize it.","commonSituations":"Running host and worker on different autogen-ext versions whose protos disagree; a custom host servicer that forgets to set typeSubscription/typePrefixSubscription; fuzzing or manual proto construction in tests.","solutions":["Pin host and all workers to the same autogen-ext version so the generated protos match","If you write a custom servicer, always populate either typeSubscription or typePrefixSubscription before sending","Log the raw message (subscription.WhichOneof('subscription')) at the receiving side to confirm which field is missing"],"exampleFix":"# before (custom servicer)\nsub = agent_worker_pb2.Subscription(id=sid)  # oneof never set\n\n# after\nsub = agent_worker_pb2.Subscription(\n    id=sid,\n    typeSubscription=agent_worker_pb2.TypeSubscription(topic_type=\"t\", agent_type=\"a\"),\n)","handlingStrategy":"validation","validationCode":"# On the sender side: verify the oneof is set before sending\nassert sub.WhichOneof(\"subscription\") in (\"typeSubscription\", \"typePrefixSubscription\"), \"malformed Subscription proto\"","typeGuard":null,"tryCatchPattern":"from autogen_ext.runtimes.grpc._utils import subscription_from_proto\ntry:\n    sub = subscription_from_proto(msg)\nexcept ValueError as e:\n    if \"Invalid subscription message\" in str(e):\n        log.warning(\"dropping malformed subscription from host: %s\", msg)\n        return None\n    raise","preventionTips":["Pin host and worker autogen-ext versions identically","Never hand-construct Subscription protos without setting the oneof","Add proto round-trip unit tests (subscription_to_proto -> subscription_from_proto)"],"tags":["python","autogen","grpc","protobuf","validation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}