{"record":{"id":"b648fa16abbc0450","repo":"Unity-Technologies/UnityCsReference","slug":"messageid-must-not-be-empty","errorCode":null,"errorMessage":"messageId must not be empty","messagePattern":"messageId must not be empty","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/EditorConnectionInternal.bindings.cs","lineNumber":27,"sourceCode":"namespace UnityEditor\n{\n    [NativeHeader(\"Runtime/Network/PlayerCommunicator/GeneralConnection.h\")]\n    enum GeneralConnectionSendMode\n    {\n        NoBlocking,\n        AllowBlocking\n    }\n\n    [StaticAccessor(\"EditorConnection::Get()\", StaticAccessorType.Dot)]\n    [NativeHeader(\"Runtime/Network/PlayerCommunicator/EditorConnection.h\")]\n    [NativeHeader(\"Runtime/Network/PlayerCommunicator/ManagedProxy/EditorConnectionManaged.h\")]\n    internal class EditorConnectionInternal : IPlayerEditorConnectionNative\n    {\n        void IPlayerEditorConnectionNative.SendMessage(Guid messageId, byte[] data, int playerId)\n        {\n            if (messageId == Guid.Empty)\n            {\n                throw new ArgumentException(nameof(messageId) + \" must not be empty\");\n            }\n            SendMessage(messageId.ToString(\"N\"), data, playerId);\n        }\n\n        bool IPlayerEditorConnectionNative.TrySendMessage(Guid messageId, byte[] data, int playerId)\n        {\n            if (messageId == Guid.Empty)\n            {\n                throw new ArgumentException(nameof(messageId) + \" must not be empty\");\n            }\n            return TrySendMessage(messageId.ToString(\"N\"), data, playerId);\n        }\n\n        void IPlayerEditorConnectionNative.Poll()\n        {\n            PollInternal();\n        }\n","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/EditorConnectionInternal.bindings.cs#L9-L45","documentation":"Thrown by EditorConnectionInternal.IPlayerEditorConnectionNative.SendMessage when the messageId Guid equals Guid.Empty. The message id is the routing key for editor↔player network messages; an empty Guid cannot be serialized as a valid message tag (it is formatted as 'N' and sent native-side). ArgumentException with the parameter name flags misuse of the API contract.","triggerScenarios":"Calling PlayerConnection / EditorConnection.Send(messageId, data) where messageId is Guid.Empty — typically because a Guid field was never assigned (default value) or was loaded from an empty string via Guid.Parse(\"\").","commonSituations":"A message-type Guid declared as `static readonly Guid kMsg = new Guid();` (defaults to Empty) instead of a generated value; deserializing a message id from config that was blank; copy-paste leaving the Guid unassigned.","solutions":["Assign a real Guid to every message id, preferably via Guid.NewGuid() at authoring time and stored as a constant.","Guard before sending: if (messageId == Guid.Empty) return; or log and skip.","Audit all message-id declarations for `new Guid()` / `default(Guid)` / Guid.Parse on untrusted input."],"exampleFix":"// before\nstatic readonly Guid kMsg = new Guid();\nconnection.Send(kMsg, bytes);\n// after\nstatic readonly Guid kMsg = new Guid(\"d3b1f8a2-....-....\"); // generated, non-empty\nconnection.Send(kMsg, bytes);","handlingStrategy":"validation","validationCode":"if (messageId == Guid.Empty) throw new ArgumentException(\"messageId must be non-empty\");\nconnection.Send(messageId, data);","typeGuard":"static bool IsValidMessageId(Guid id) => id != Guid.Empty;","tryCatchPattern":null,"preventionTips":["Initialize every message-id constant with an explicit generated Guid.","Never declare Guid fields relying on the default (Empty) value for routing.","Validate Guids parsed from untrusted input before sending."],"tags":["editor","networking","editorconnection","guid","validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}