{"record":{"id":"6276a30f3156f7e8","repo":"egametang/ET","slug":"location-primary-actor-id-is-empty-primaryscenen","errorCode":null,"errorMessage":"location primary actor id is empty: {primarySceneName}","messagePattern":"location primary actor id is empty: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.actorlocation/Scripts/Hotfix/Server/LocationProxyComponentSystem.cs","lineNumber":126,"sourceCode":"            while (true)\n            {\n                self = selfRef;\n                if (self == null)\n                {\n                    throw new Exception(\"location proxy disposed\");\n                }\n\n                string primarySceneName = string.Empty;\n                ulong primaryPriorityId = 0;\n                try\n                {\n                    primarySceneName = self.GetPrimaryLocationSceneName();\n                    primaryPriorityId = self.primaryLocationPriorityId;\n                    ServiceDiscoveryProxy serviceDiscoveryProxy = self.Root().GetComponent<ServiceDiscoveryProxy>();\n                    ActorId primaryActorId = serviceDiscoveryProxy.GetServiceInfo(primarySceneName).ActorId;\n                    if (primaryActorId == default)\n                    {\n                        throw new Exception($\"location primary actor id is empty: {primarySceneName}\");\n                    }\n\n                    MessageSender messageSender = self.Root().GetComponent<MessageSender>();\n                    if (messageSender == null)\n                    {\n                        throw new Exception($\"location proxy message sender is null: {self.Root().Name}\");\n                    }\n\n                    IResponse response = await messageSender.Call(primaryActorId, request);\n                    if (response.Error == ErrorCode.ERR_LocationFollowerRejected\n                        || response.Error == ErrorCode.ERR_LocationPrimaryUnavailable)\n                    {\n                        ++retryCount;\n                        self = selfRef;\n                        if (self == null)\n                        {\n                            return response;\n                        }","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.actorlocation/Scripts/Hotfix/Server/LocationProxyComponentSystem.cs#L108-L144","documentation":"Thrown by CallPrimaryWithRetry when the primary Location scene's ServiceInfo exists (was discovered) but its ActorId is default (zero). An ActorId of zero means the scene is registered but not addressable -- no actor is actually running at that address. This is an inconsistency between service discovery state and actual runtime state.","triggerScenarios":"serviceDiscoveryProxy.GetServiceInfo(primarySceneName).ActorId returns default(ActorId). This means the ServiceInfo entity has SceneName and Metadata but its ActorId was never set or was reset to zero during teardown.","commonSituations":"The Location scene is shutting down and its ServiceInfo was partially cleaned (ActorId zeroed but not yet removed from discovery); a race between scene teardown and service discovery update; a bug in service discovery registration that doesn't set ActorId.","solutions":["Wait for the Location scene to fully restart and re-register with a valid ActorId -- CallPrimaryWithRetry will retry.","Check service discovery logs for proper ActorId registration.","If persistent, investigate why ServiceInfo.ActorId is zero -- look at ServiceInfoSystem initialization."],"exampleFix":"// No direct code fix -- this is a service discovery state issue.\n// Verify the Location scene's ServiceInfo has a valid ActorId:\n// Log.Info($\"location scene actorId: {serviceInfo.ActorId}\");\n// If zero, the scene needs to re-register with service discovery.","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// CallPrimaryWithRetry catches this as a generic Exception and retries.\n// At the top level:\ntry\n{\n    await locationProxy.Add(type, key, actorId);\n}\ncatch (Exception e) when (e.Message.Contains(\"location primary actor id is empty\"))\n{\n    Log.Error($\"Primary scene registered but has no valid ActorId: {e.Message}\");\n}","preventionTips":["Ensure Location scenes register with a valid ActorId in service discovery.","Monitor service discovery for entries with zero/default ActorId.","During Location scene restarts, allow time for re-registration before expecting location operations to succeed."],"tags":["location","service-discovery","primary-election","actor","infrastructure"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}