{"record":{"id":"a57d2db67f3f6ed3","repo":"Unity-Technologies/UnityCsReference","slug":"cant-be-guid-empty","errorCode":null,"errorMessage":"Cant be Guid.Empty","messagePattern":"Cant be Guid\\.Empty","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Networking/PlayerConnection/EditorConnection.cs","lineNumber":107,"sourceCode":"        private void UnregisterAllPersistedListeners(UnityEventBase connectionEvent)\n        {\n            var persistentEventCount = connectionEvent.GetPersistentEventCount();\n            for (int i = 0; i < persistentEventCount; i++)\n            {\n                connectionEvent.UnregisterPersistentListener(i);\n            }\n        }\n\n        private IPlayerEditorConnectionNative GetEditorConnectionNativeApi()\n        {\n            return connectionNative ?? new EditorConnectionInternal();\n        }\n\n        public void Register(Guid messageId, UnityAction<MessageEventArgs> callback)\n        {\n            if (messageId == Guid.Empty)\n            {\n                throw new ArgumentException(\"Cant be Guid.Empty\", \"messageId\");\n            }\n\n            if (!m_PlayerEditorConnectionEvents.messageTypeSubscribers.Exists(x => x.MessageTypeId == messageId))\n            {\n                GetEditorConnectionNativeApi().RegisterInternal(messageId);\n            }\n\n            m_PlayerEditorConnectionEvents.AddAndCreate(messageId)\n                .AddPersistentListener(callback, UnityEventCallState.EditorAndRuntime);\n        }\n\n        public void Unregister(Guid messageId, UnityAction<MessageEventArgs> callback)\n        {\n            m_PlayerEditorConnectionEvents.UnregisterManagedCallback(messageId, callback);\n            if (!m_PlayerEditorConnectionEvents.messageTypeSubscribers.Exists(x => x.MessageTypeId == messageId))\n            {\n                GetEditorConnectionNativeApi().UnregisterInternal(messageId);\n            }","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Networking/PlayerConnection/EditorConnection.cs#L89-L125","documentation":"Thrown by EditorConnection.Register when the messageId Guid equals Guid.Empty. Empty GUIDs are rejected because the native subscription layer needs a well-formed message identifier.","triggerScenarios":"Calling EditorConnection.Register(Guid.Empty, callback) — passing an uninitialized Guid field or default(Guid).","commonSituations":"MessageId constant forgotten/never assigned, or a field left at its default. Copy-paste where the Guid was meant to be Guid.NewGuid() or a known message ID.","solutions":["Define a stable Guid for the message ID (Guid.Parse of a fixed string).","Use a well-known message ID constant shared between editor and player.","Validate messageId != Guid.Empty at the call site."],"exampleFix":"// before\nconnection.Register(Guid.Empty, OnMsg);\n// after\nstatic readonly Guid k_MsgId = new Guid(\"d1b8...-...\");\nconnection.Register(k_MsgId, OnMsg);","handlingStrategy":"validation","validationCode":"if (messageId != Guid.Empty) connection.Register(messageId, callback);","typeGuard":"static bool IsValidMessageId(Guid id) => id != Guid.Empty;","tryCatchPattern":null,"preventionTips":["Define message IDs as static readonly Guid constants.","Never pass default(Guid) to connection APIs."],"tags":["unity","player-connection","guid","validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}