{"record":{"id":"0c61fa2969b1f2fa","repo":"microsoft/semantic-kernel","slug":"unknown-type-type-name-with-content-type-data-c","errorCode":null,"errorMessage":"Unknown type {type_name} with content type {data_content_type}","messagePattern":"Unknown type (.+?) with content type (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/runtime/core/serialization.py","lineNumber":306,"sourceCode":"            for c in serializer:\n                self.add_serializer(c)\n            return\n\n        self._serializers[serializer.type_name, serializer.data_content_type] = serializer\n\n    def deserialize(self, payload: bytes, *, type_name: str, data_content_type: str) -> Any:\n        \"\"\"Deserialize a payload into a message.\"\"\"\n        serializer = self._serializers.get((type_name, data_content_type))\n        if serializer is None:\n            return UnknownPayload(type_name, data_content_type, payload)\n\n        return serializer.deserialize(payload)\n\n    def serialize(self, message: Any, *, type_name: str, data_content_type: str) -> bytes:\n        \"\"\"Serialize a message into a payload.\"\"\"\n        serializer = self._serializers.get((type_name, data_content_type))\n        if serializer is None:\n            raise ValueError(f\"Unknown type {type_name} with content type {data_content_type}\")\n\n        return serializer.serialize(message)\n\n    def is_registered(self, type_name: str, data_content_type: str) -> bool:\n        \"\"\"Check if a type is registered in the registry.\"\"\"\n        return (type_name, data_content_type) in self._serializers\n\n    def type_name(self, message: Any) -> str:\n        \"\"\"Get the type name of a message.\"\"\"\n        return _type_name(message)\n","sourceCodeStart":288,"sourceCodeEnd":317,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/runtime/core/serialization.py#L288-L317","documentation":"Raised by SerializationRegistry.serialize when no serializer is registered for the exact (type_name, data_content_type) tuple. Note the asymmetry: deserialize returns an UnknownPayload sentinel instead of raising, while serialize raises ValueError. Mismatches in either the type name (class __name__ vs protobuf DESCRIPTOR.full_name) or the content-type string cause a lookup miss.","triggerScenarios":"Calling registry.serialize(msg, type_name=..., data_content_type=...) for a pair that was never added via add_serializer; using a content-type string that differs from the serializer's data_content_type (e.g. 'application/json' vs the library constant); a type_name that does not match the serializer's type_name; using a freshly constructed empty registry.","commonSituations":"Forgetting to register a serializer; reconstructing a registry without re-registering; content-type string drift between producer and consumer; using the class's qualified name instead of __name__.","solutions":["Register the serializer before serializing via registry.add_serializer(...).","Ensure type_name matches the serializer's type_name and data_content_type matches exactly (use the library constants).","Check registry.is_registered(type_name, data_content_type) before serializing.","Reuse the runtime's pre-populated registry rather than an empty one."],"exampleFix":"// before\nregistry = SerializationRegistry()\nregistry.serialize(msg, type_name='MyMsg', data_content_type='application/json')  # not registered -> ValueError\n\n// after\nfrom semantic_kernel.agents.runtime.core.serialization import PydanticJsonMessageSerializer, JSON_DATA_CONTENT_TYPE\nregistry.add_serializer(PydanticJsonMessageSerializer(MyMsg))\nregistry.serialize(msg, type_name='MyMsg', data_content_type=JSON_DATA_CONTENT_TYPE)","handlingStrategy":"validation","validationCode":"def can_serialize(registry, type_name: str, data_content_type: str) -> bool:\n    return registry.is_registered(type_name, data_content_type)","typeGuard":null,"tryCatchPattern":"try:\n    payload = registry.serialize(msg, type_name=tn, data_content_type=ct)\nexcept ValueError as e:\n    logger.error('Type/content-type not registered: %s', e)","preventionTips":["Register every serializer before first use.","Reuse the runtime's registry; do not construct an empty one for sending.","Always pass the serializer's own type_name and data_content_type, preferably via library constants.","Guard with is_registered before serializing."],"tags":["serialization","registry","content-type"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}