{"record":{"id":"9d85eaf040204d0f","repo":"EllanJiang/GameFramework","slug":"serialized-packet-failure","errorCode":null,"errorMessage":"Serialized packet failure.","messagePattern":"Serialized packet failure\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Network/NetworkManager.NetworkChannelBase.cs","lineNumber":535,"sourceCode":"                        {\n                            SocketException socketException = exception as SocketException;\n                            NetworkChannelError(this, NetworkErrorCode.SerializeError, socketException != null ? socketException.SocketErrorCode : SocketError.Success, exception.ToString());\n                            return false;\n                        }\n\n                        throw;\n                    }\n\n                    if (!serializeResult)\n                    {\n                        string errorMessage = \"Serialized packet failure.\";\n                        if (NetworkChannelError != null)\n                        {\n                            NetworkChannelError(this, NetworkErrorCode.SerializeError, SocketError.Success, errorMessage);\n                            return false;\n                        }\n\n                        throw new GameFrameworkException(errorMessage);\n                    }\n                }\n\n                m_SendState.Stream.Position = 0L;\n                return true;\n            }\n\n            protected virtual void ProcessReceive()\n            {\n            }\n\n            protected virtual bool ProcessPacketHeader()\n            {\n                try\n                {\n                    object customErrorData = null;\n                    IPacketHeader packetHeader = m_NetworkChannelHelper.DeserializePacketHeader(m_ReceiveState.Stream, out customErrorData);\n","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Network/NetworkManager.NetworkChannelBase.cs#L517-L553","documentation":"In ProcessSend (run from the channel Update loop), the registered INetworkChannelHelper's serialization of the queued packet failed; the helper signals failure via its error message and GameFramework throws GameFrameworkException (or fires NetworkChannelError with NetworkErrorCode.SerializeError). This means the packet could not be converted to bytes for the wire.","triggerScenarios":"A PacketHandler/Serialize call returning false for the packet type; sending a packet type the helper's serializer does not know how to handle; serializer internal failure (e.g. unsupported field, buffer overflow in the packet header length).","commonSituations":"Adding a new packet class without registering a serializer in the custom NetworkChannelHelper; protocol changes where the client serializes a message the helper's format cannot encode; serializing payloads exceeding the configured packet-length limits.","solutions":["Implement/fix the Serialize branch in your INetworkChannelHelper (PacketHandler) for the failing packet's Type.","Check the packet's fields against the serialization format; fix data that cannot be encoded (e.g. oversized strings, wrong types).","Log the packet type at failure to find which class lacks serializer support.","Register NetworkChannelError to catch NetworkErrorCode.SerializeError and drop/blacklist the bad packet instead of crashing."],"exampleFix":"// before\n// NetworkChannelHelper.PacketHandler has no case for MyNewPacket\n// after\nswitch (packet.GetType().Name) {\n    case \"MyNewPacket\":\n        stream.Write(...);\n        return true;\n}","handlingStrategy":"try-catch","validationCode":"// Ensure every packet type has a serializer before sending\nif (!channelHelper.CanSerialize(packet.GetType())) throw new InvalidOperationException($\"No serializer for {packet.GetType().Name}\");","typeGuard":null,"tryCatchPattern":"networkManager.NetworkChannelError += (channel, code, socketError, msg) => { if (code == NetworkErrorCode.SerializeError) DropPacketAndLog(channel, msg); };","preventionTips":["Register a serializer case for every new Packet subclass","Add a unit test that serializes every known packet type","Validate payloads against protocol limits (string lengths, field sizes) before sending","Log packet.GetType() in the helper's failure branch"],"tags":["network","serialization","gameframework"],"backgroundTag":"json-marshal-failed","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}