{"record":{"id":"1b3859217f8c8428","repo":"microsoft/autogen","slug":"unsupported-message-content-type-message-content","errorCode":null,"errorMessage":"Unsupported message content type: {message_content_type}","messagePattern":"Unsupported message content type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py","lineNumber":634,"sourceCode":"        topic_id = TopicId(event.type, event.source)\n        # Get the recipients for the topic.\n        recipients = await self._subscription_manager.get_subscribed_recipients(topic_id)\n\n        message_content_type = event_attributes[_constants.DATA_CONTENT_TYPE_ATTR].ce_string\n        message_type = event_attributes[_constants.DATA_SCHEMA_ATTR].ce_string\n\n        if message_content_type == JSON_DATA_CONTENT_TYPE:\n            message = self._serialization_registry.deserialize(\n                event.binary_data, type_name=message_type, data_content_type=message_content_type\n            )\n        elif message_content_type == PROTOBUF_DATA_CONTENT_TYPE:\n            # TODO: find a way to prevent the roundtrip serialization\n            proto_binary_data = event.proto_data.SerializeToString()\n            message = self._serialization_registry.deserialize(\n                proto_binary_data, type_name=message_type, data_content_type=message_content_type\n            )\n        else:\n            raise ValueError(f\"Unsupported message content type: {message_content_type}\")\n\n        # TODO: dont read these values in the runtime\n        topic_type_suffix = topic_id.type.split(\":\", maxsplit=1)[1] if \":\" in topic_id.type else \"\"\n        is_rpc = topic_type_suffix == _constants.MESSAGE_KIND_VALUE_RPC_REQUEST\n        is_marked_rpc_type = (\n            _constants.MESSAGE_KIND_ATTR in event_attributes\n            and event_attributes[_constants.MESSAGE_KIND_ATTR].ce_string == _constants.MESSAGE_KIND_VALUE_RPC_REQUEST\n        )\n        if is_rpc and not is_marked_rpc_type:\n            warnings.warn(\"Received RPC request with topic type suffix but not marked as RPC request.\", stacklevel=2)\n\n        # Send the message to each recipient.\n        responses: List[Awaitable[Any]] = []\n        for agent_id in recipients:\n            if agent_id == sender:\n                continue\n            message_context = MessageContext(\n                sender=sender,","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py#L616-L652","documentation":"When a CloudEvent arrives, GrpcWorkerAgentRuntime._process_event deserializes the payload according to the event's datacontenttype. Only JSON_DATA_CONTENT_TYPE and PROTOBUF_DATA_CONTENT_TYPE are recognized; any other content type raises ValueError('Unsupported message content type: ...') and the event is dropped (logged as a read-loop/background-task error).","triggerScenarios":"Another worker or host publishes a CloudEvent with datacontenttype set to something other than application/json or application/x-protobuf while this worker is subscribed to the topic — e.g. a producer with a different payload_serialization_format, or an external event injected into the host.","commonSituations":"Mixing worker versions or configs where one uses JSON and another a custom/protobuf-ish MIME string; publishing events into the host from non-AutoGen producers; typos in content-type strings.","solutions":["Make all producers use one of the supported formats: configure payload_serialization_format with the JSON_DATA_CONTENT_TYPE or PROTOBUF_DATA_CONTENT_TYPE constant, not a free-form string","Pin all workers to compatible autogen-ext versions so content types agree","If external systems inject CloudEvents, convert their payloads to application/json before they reach subscribed workers"],"exampleFix":"# before (producer side)\nruntime = GrpcWorkerAgentRuntime(host, payload_serialization_format=\"application/vnd.custom\")\n\n# after\nfrom autogen_ext.runtimes.grpc._constants import JSON_DATA_CONTENT_TYPE\nruntime = GrpcWorkerAgentRuntime(host, payload_serialization_format=JSON_DATA_CONTENT_TYPE)","handlingStrategy":"validation","validationCode":"from autogen_ext.runtimes.grpc._constants import JSON_DATA_CONTENT_TYPE, PROTOBUF_DATA_CONTENT_TYPE\n\nSUPPORTED = {JSON_DATA_CONTENT_TYPE, PROTOBUF_DATA_CONTENT_TYPE}\n\n# verify config of every producer before start\nassert runtime_payload_format in SUPPORTED, \"all workers must use a supported content type\"","typeGuard":null,"tryCatchPattern":"try:\n    await runtime.publish_message(msg, topic)\nexcept ValueError as e:\n    # note: content-type rejection happens on the receiving worker; catch there:\n    # errors surface via background-task logging — monitor logs for 'Unsupported message content type'\n    raise","preventionTips":["Standardize payload_serialization_format across all workers via shared config","Use the module constants instead of literal strings","Pin all workers and the host to the same autogen-ext version","Monitor worker logs for read-loop errors to catch mismatched producers"],"tags":["python","autogen","grpc","serialization","cloudevents","validation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}