{"record":{"id":"5359af80903515c9","repo":"Unity-Technologies/UnityCsReference","slug":"can-not-be-guid-empty","errorCode":null,"errorMessage":"Can not be Guid.Empty","messagePattern":"Can not be Guid\\.Empty","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Networking/PlayerConnection/EditorConnection.cs","lineNumber":156,"sourceCode":"        {\n            m_PlayerEditorConnectionEvents.disconnectionEvent.AddPersistentListener(callback, UnityEventCallState.EditorAndRuntime);\n        }\n\n        public void UnregisterConnection(UnityAction<int> callback)\n        {\n            m_PlayerEditorConnectionEvents.connectionEvent.RemovePersistentListener((UnityEngine.Object)callback.Target, callback.Method);\n        }\n\n        public void UnregisterDisconnection(UnityAction<int> callback)\n        {\n            m_PlayerEditorConnectionEvents.disconnectionEvent.RemovePersistentListener((UnityEngine.Object)callback.Target, callback.Method);\n        }\n\n        public void Send(Guid messageId, byte[] data, int playerId)\n        {\n            if (messageId == Guid.Empty)\n            {\n                throw new ArgumentException(\"Can not be Guid.Empty\", \"messageId\");\n            }\n\n            GetEditorConnectionNativeApi().SendMessage(messageId, data, playerId);\n        }\n\n        public void Send(Guid messageId, byte[] data)\n        {\n            Send(messageId, data, 0);\n        }\n\n        public bool TrySend(Guid messageId, byte[] data, int playerId)\n        {\n            if (messageId == Guid.Empty)\n            {\n                throw new ArgumentException(\"Can not be Guid.Empty\", \"messageId\");\n            }\n\n            return GetEditorConnectionNativeApi().TrySendMessage(messageId, data, playerId);","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Networking/PlayerConnection/EditorConnection.cs#L138-L174","documentation":"Thrown by EditorConnection.Send(messageId, data, playerId) when messageId is Guid.Empty. Same invariant as Register: every sent message must carry a valid identifier so the player can route it.","triggerScenarios":"Calling Send with a default/uninitialized Guid, or a messageId variable that was never set.","commonSituations":"Sending before subscribing to a known message ID; hardcoded empty Guid in test code; message-ID constant refactored away.","solutions":["Use the same non-empty message Guid used at registration time.","Guard with a check or use TrySend which also validates (and returns false rather than throwing only on the native side).","Centralize message IDs in a shared constants class."],"exampleFix":"// before\nconnection.Send(Guid.Empty, bytes, playerId);\n// after\nconnection.Send(k_MsgId, bytes, playerId);","handlingStrategy":"validation","validationCode":"if (messageId != Guid.Empty) connection.Send(messageId, data, playerId);","typeGuard":"static bool IsValidMessageId(Guid id) => id != Guid.Empty;","tryCatchPattern":null,"preventionTips":["Reuse the same Guid registered at subscription time.","Centralize message IDs in a shared constants class."],"tags":["unity","player-connection","guid","send"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}