Unity-Technologies/UnityCsReference · error · ArgumentException
messageId must not be empty
Error message
messageId must not be empty
What it means
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.
Source
Thrown at Editor/Mono/EditorConnectionInternal.bindings.cs:27
namespace UnityEditor
{
[NativeHeader("Runtime/Network/PlayerCommunicator/GeneralConnection.h")]
enum GeneralConnectionSendMode
{
NoBlocking,
AllowBlocking
}
[StaticAccessor("EditorConnection::Get()", StaticAccessorType.Dot)]
[NativeHeader("Runtime/Network/PlayerCommunicator/EditorConnection.h")]
[NativeHeader("Runtime/Network/PlayerCommunicator/ManagedProxy/EditorConnectionManaged.h")]
internal class EditorConnectionInternal : IPlayerEditorConnectionNative
{
void IPlayerEditorConnectionNative.SendMessage(Guid messageId, byte[] data, int playerId)
{
if (messageId == Guid.Empty)
{
throw new ArgumentException(nameof(messageId) + " must not be empty");
}
SendMessage(messageId.ToString("N"), data, playerId);
}
bool IPlayerEditorConnectionNative.TrySendMessage(Guid messageId, byte[] data, int playerId)
{
if (messageId == Guid.Empty)
{
throw new ArgumentException(nameof(messageId) + " must not be empty");
}
return TrySendMessage(messageId.ToString("N"), data, playerId);
}
void IPlayerEditorConnectionNative.Poll()
{
PollInternal();
}
View on GitHub (pinned to 225b0fbdb5)
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.
Example fix
// before
static readonly Guid kMsg = new Guid();
connection.Send(kMsg, bytes);
// after
static readonly Guid kMsg = new Guid("d3b1f8a2-....-...."); // generated, non-empty
connection.Send(kMsg, bytes); Defensive patterns
Strategy: validation
Validate before calling
if (messageId == Guid.Empty) throw new ArgumentException("messageId must be non-empty");
connection.Send(messageId, data); Type guard
static bool IsValidMessageId(Guid id) => id != Guid.Empty;
Prevention
- 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.
When it happens
Trigger: 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("").
Common situations: 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.
Related errors
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/b648fa16abbc0450.
Report an issue: GitHub.