{"record":{"id":"2d5448ee6c90814e","repo":"alibaba/nacos","slug":"400-2d5448","errorCode":"-400","errorMessage":"wrong group name prefix of instance service name! it should be: %s, Instance: %s","messagePattern":"wrong group name prefix of instance service name! it should be: (.+?), Instance: (.+?)","errorType":"exception","errorClass":"NacosException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java","lineNumber":727,"sourceCode":"        clientProxy.shutdown();\n        namingFuzzyWatchServiceListHolder.shutdown();\n        NotifyCenter.deregisterSubscriber(changeNotifier);\n    }\n    \n    private void batchCheckAndStripGroupNamePrefix(List<Instance> instances, String groupName)\n        throws NacosException {\n        for (Instance instance : instances) {\n            checkAndStripGroupNamePrefix(instance, groupName);\n        }\n    }\n    \n    private void checkAndStripGroupNamePrefix(Instance instance, String groupName)\n        throws NacosException {\n        String serviceName = instance.getServiceName();\n        if (NamingUtils.isServiceNameCompatibilityMode(serviceName)) {\n            String groupNameOfInstance = NamingUtils.getGroupName(serviceName);\n            if (!groupName.equals(groupNameOfInstance)) {\n                throw new NacosException(NacosException.CLIENT_INVALID_PARAM, String.format(\n                    \"wrong group name prefix of instance service name! it should be: %s, Instance: %s\",\n                    groupName,\n                    instance));\n            }\n            instance.setServiceName(NamingUtils.getServiceName(serviceName));\n        }\n    }\n    \n    private void notifyIfSubscribed(String serviceName, String groupName,\n        NamingSelectorWrapper wrapper)\n        throws NacosException {\n        if (clientProxy.isSubscribed(serviceName, groupName, StringUtils.EMPTY)) {\n            NAMING_LOGGER.warn(\n                \"Duplicate subscribe for groupName: {}, serviceName: {}; directly use current cached to notify.\",\n                groupName, serviceName);\n            ServiceInfo serviceInfo = serviceInfoHolder.getServiceInfo(serviceName, groupName);\n            InstancesChangeEvent event = transferToEvent(serviceInfo);\n            wrapper.notifyListener(event);","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java#L709-L745","documentation":"Thrown by NacosNamingService.checkAndStripGroupNamePrefix when an Instance's serviceName is in compatibility mode (contains a group prefix like 'GROUP_NAME@@serviceName') but the embedded group does not match the groupName argument passed to the register/batch API. The client enforces consistency: if you supply a serviceName with a legacy '@@' group prefix, that prefix must equal the groupName parameter. Code CLIENT_INVALID_PARAM (-400).","triggerScenarios":"Calling registerInstance(serviceName='DEFAULT_GROUP@@foo', groupName='OTHER') where the prefix DEFAULT_GROUP differs from OTHER; batch registerInstance with instances whose embedded group prefixes disagree with the supplied group; mixing legacy '@@'-prefixed service names with the explicit groupName overload.","commonSituations":"Migrating from the legacy single-name API (which embeds group via '@@') to the explicit (groupName, serviceName) overloads; copy-pasting service names that include a group prefix while also passing a different group argument; inconsistent group conventions across services.","solutions":["Make the serviceName's '@@' prefix match the groupName argument, OR omit the prefix from serviceName and pass the group only via the groupName parameter.","Sanitize instance service names before registration to strip any '@@' prefix when using the explicit-group overloads.","Adopt one convention project-wide: either always use 'GROUP@@name' or always use separate (group, name) parameters."],"exampleFix":"// before\ninstance.setServiceName(\"DEFAULT_GROUP@@order-service\");\nnaming.registerInstance(\"order-service\", \"PROD_GROUP\", instance); // throws -400\n\n// after — keep them consistent\ninstance.setServiceName(\"order-service\"); // no prefix\nnaming.registerInstance(\"order-service\", \"PROD_GROUP\", instance);","handlingStrategy":"validation","validationCode":"// Strip any @@ group prefix before using the explicit-group overloads\nString raw = instance.getServiceName();\nif (raw != null && raw.contains(\"@@\")) {\n    String embeddedGroup = raw.substring(0, raw.indexOf(\"@@\"));\n    if (!embeddedGroup.equals(groupName)) {\n        throw new IllegalArgumentException(\"Service name group prefix mismatch\");\n    }\n    instance.setServiceName(raw.substring(raw.indexOf(\"@@\") + 2));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Adopt one convention: either 'GROUP@@name' or separate (group, name), not both.","Sanitize imported service names before registration.","Validate that serviceName's embedded group matches the groupName argument."],"tags":["naming","group-name","validation","compatibility-mode","invalid-param"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}