microsoft/autogen · error · ValueError
Invalid subscription message.
Error message
Invalid subscription message.
What it means
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.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_utils.py:45
oneofcase = subscription.WhichOneof("subscription")
match oneofcase:
case "typeSubscription":
type_subscription_msg: agent_worker_pb2.TypeSubscription = subscription.typeSubscription
return TypeSubscription(
topic_type=type_subscription_msg.topic_type,
agent_type=type_subscription_msg.agent_type,
id=subscription.id,
)
case "typePrefixSubscription":
type_prefix_subscription_msg: agent_worker_pb2.TypePrefixSubscription = subscription.typePrefixSubscription
return TypePrefixSubscription(
topic_type_prefix=type_prefix_subscription_msg.topic_type_prefix,
agent_type=type_prefix_subscription_msg.agent_type,
id=subscription.id,
)
case None:
raise ValueError("Invalid subscription message.")
View on GitHub (pinned to 027ecf0a37)
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
Example fix
# before (custom servicer)
sub = agent_worker_pb2.Subscription(id=sid) # oneof never set
# after
sub = agent_worker_pb2.Subscription(
id=sid,
typeSubscription=agent_worker_pb2.TypeSubscription(topic_type="t", agent_type="a"),
) Defensive patterns
Strategy: validation
Validate before calling
# On the sender side: verify the oneof is set before sending
assert sub.WhichOneof("subscription") in ("typeSubscription", "typePrefixSubscription"), "malformed Subscription proto" Try / catch
from autogen_ext.runtimes.grpc._utils import subscription_from_proto
try:
sub = subscription_from_proto(msg)
except ValueError as e:
if "Invalid subscription message" in str(e):
log.warning("dropping malformed subscription from host: %s", msg)
return None
raise Prevention
- 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)
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unsupported subscription type.
- Unsupported payload serialization format: {payload_serializa
- Unsupported message content type: {message_content_type}
- Tool names must be unique: {tool_names}
- Maximum number of tool iterations must be greater than or eq
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/7f65c301248dc761.
Report an issue: GitHub.