egametang/ET · error · ArgumentException

ServiceAgentRegisterRequest invalid: AgentActorId is empty.

Error message

ServiceAgentRegisterRequest invalid: AgentActorId is empty.

What it means

ArgumentException thrown at line 722 in TryRegisterAgentToDiscoveryAsync: ServiceDiscoveryHelpers.TryValidateRequiredActorId failed because request.AgentActorId (set from self.Root().GetActorId()) is empty/default. The agent cannot register with the master without a valid own ActorId/address, so registration is rejected upfront.

Source

Thrown at Packages/cn.etetet.servicediscovery/Scripts/Hotfix/Server/ServiceDiscoveryAgentSystem.cs:722

            if (self == null)
            {
                return false;
            }

            if (self.ServiceDiscoveryActorId == default)
            {
                return false;
            }

            EntityRef<ServiceDiscoveryAgent> selfRef = self;
            ActorId targetActorId = self.ServiceDiscoveryActorId;
            ServiceAgentRegisterRequest request = ServiceAgentRegisterRequest.Create();
            request.AgentActorId = self.Root().GetActorId();
            Address ownedAddress = request.AgentActorId.Address;
            if (!ServiceDiscoveryHelper.TryValidateRequiredActorId(request.AgentActorId, nameof(ServiceAgentRegisterRequest),
                    nameof(request.AgentActorId), out string errorMessage))
            {
                throw new ArgumentException(errorMessage);
            }

            self.AppendOwnedLocalServices(request);

            try
            {
                TimerComponent timer = self.Root().TimerComponent;
                ETTask<IResponse> registerTask = self.MessageSender.Call(targetActorId, request);
                IResponse rawResponse = await registerTask;
                self = selfRef;
                if (self == null)
                {
                    (rawResponse as MessageObject)?.Dispose();
                    return false;
                }

                if (rawResponse is not ServiceAgentRegisterResponse response)
                {

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Defer TriggerBackgroundRegister until the scene has a valid ActorId (ensure Root().GetActorId() != default before registering).
  2. Verify scene creation provides a concrete ProcessId/Address so GetActorId() is populated.
  3. Move registration initiation to a later lifecycle hook where identity is guaranteed.

Example fix

// before
public static void Awake(this ServiceDiscoveryAgent self)
{
    self.EnsureBackgroundRegisterStarted(); // may run before ActorId set
}

// after: guard registration on a valid ActorId
if (self.Root().GetActorId() != default)
{
    self.EnsureBackgroundRegisterStarted();
}
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the scene has a valid ActorId before triggering registration.
if (self.Root().GetActorId() == default)
{
    Log.Warning("scene ActorId not yet assigned; deferring discovery registration");
    return; // retry later
}

Try / catch

catch (ArgumentException e) when (e.Message.Contains("AgentActorId is empty"))
{
    Log.Warning($"deferred registration, ActorId not ready: {e.Message}");
    // schedule a retry once the scene identity is set
}

Prevention

When it happens

Trigger: TriggerBackgroundRegister/TryRegisterAgentToDiscoveryAsync runs before the agent's Root Scene has a valid ActorId assigned — GetActorId() returns default because the scene/fiber identity is not yet initialized. Also possible if the scene's Process/Address is unset.

Common situations: Registration triggered too early in scene Awake (before ActorId is assigned); a scene created without a proper Address/Process binding; startup ordering where background registration fires during partial initialization.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/9d42254d1a881f8e. Report an issue: GitHub.