{"record":{"id":"8212f778136f9e21","repo":"alibaba/nacos","slug":"400-8212f7","errorCode":"400","errorMessage":"Current service %s is ephemeral service, can't register persistent instance.","messagePattern":"Current service (.+?) is ephemeral service, can't register persistent instance\\.","errorType":"validation","errorClass":"NacosRuntimeException","httpStatus":null,"severity":"error","filePath":"naming/src/main/java/com/alibaba/nacos/naming/core/v2/service/impl/PersistentClientOperationServiceImpl.java","lineNumber":110,"sourceCode":"    private final CPProtocol protocol;\n    \n    private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();\n    \n    private final ReentrantReadWriteLock.ReadLock readLock = lock.readLock();\n    \n    private static final int INITIAL_CAPACITY = 128;\n    \n    public PersistentClientOperationServiceImpl(final PersistentIpPortClientManager clientManager) {\n        this.clientManager = clientManager;\n        this.protocol = ApplicationUtils.getBean(ProtocolManager.class).getCpProtocol();\n        this.protocol.addRequestProcessors(Collections.singletonList(this));\n    }\n    \n    @Override\n    public void registerInstance(Service service, Instance instance, String clientId) {\n        Service singleton = ServiceManager.getInstance().getSingleton(service);\n        if (singleton.isEphemeral()) {\n            throw new NacosRuntimeException(NacosException.INVALID_PARAM,\n                String.format(\n                    \"Current service %s is ephemeral service, can't register persistent instance.\",\n                    singleton.getGroupedServiceName()));\n        }\n        final InstanceStoreRequest request = new InstanceStoreRequest();\n        request.setService(service);\n        request.setInstance(instance);\n        request.setClientId(clientId);\n        final WriteRequest writeRequest = WriteRequest.newBuilder().setGroup(group())\n            .setData(ByteString.copyFrom(serializer.serialize(request)))\n            .setOperation(DataOperation.ADD.name())\n            .build();\n        \n        try {\n            protocol.write(writeRequest);\n            Loggers.RAFT.info(\"Client registered. service={}, clientId={}, instance={}\", service,\n                clientId, instance);\n        } catch (Exception e) {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/naming/src/main/java/com/alibaba/nacos/naming/core/v2/service/impl/PersistentClientOperationServiceImpl.java#L92-L128","documentation":"Thrown by PersistentClientOperationServiceImpl.registerInstance when the service singleton IS ephemeral but the registration targets the persistent path. Error code 400 (INVALID_PARAM) via NacosRuntimeException. This is the mirror of the ephemeral-path rejection: a persistent instance can only be registered against a persistent (ephemeral=false) service.","triggerScenarios":"A client registers a persistent instance (ephemeral=false) against a service that was created with ephemeral=true. The PersistentClientOperationServiceImpl resolves the singleton, finds it ephemeral, and rejects. This path is used for HTTP-based beat-style registration and explicit persistent gRPC registration.","commonSituations":"Service created as ephemeral (the default in many SDKs) but the client tries to register a persistent instance. Migration where the service type was changed but the client config was not updated. v1 HTTP API registration of a persistent instance against a v2 ephemeral service.","solutions":["Align the instance ephemeral flag with the service: register ephemeral instances against ephemeral services.","Recreate the service with ephemeral=false if persistent instances are intended.","Explicitly set instance.setEphemeral(true) if the service is ephemeral.","Query the service metadata to verify its ephemeral flag before registering."],"exampleFix":"// before — service is ephemeral, instance is persistent\nInstance inst = new Instance();\ninst.setEphemeral(false); // mismatch!\nnamingService.registerInstance(service, inst);\n\n// after — match the ephemeral service\nInstance inst = new Instance();\ninst.setEphemeral(true);\nnamingService.registerInstance(service, inst);","handlingStrategy":"validation","validationCode":"Service singleton = ServiceManager.getInstance().getSingleton(service);\nif (singleton.isEphemeral()) {\n    // service is ephemeral — cannot register persistent instance\n    // either set instance.ephemeral=true or recreate service as persistent\n    instance.setEphemeral(true);\n}\npersistentClientOperationService.registerInstance(service, instance, clientId);","typeGuard":null,"tryCatchPattern":"try {\n    persistentClientOperationService.registerInstance(service, instance, clientId);\n} catch (NacosRuntimeException e) {\n    if (e.getErrCode() == NacosException.INVALID_PARAM\n            && e.getMessage().contains(\"ephemeral service\")) {\n        // route to ephemeral registration path instead\n        ephemeralClientOperationService.registerInstance(service, instance, clientId);\n    } else throw e;\n}","preventionTips":["Set instance.setEphemeral() to match the service definition before registering.","Query service metadata to confirm the ephemeral flag.","Recreate the service with the intended ephemeral flag before mixing instance types."],"tags":["naming","instance-register","persistent","type-mismatch","validation"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}