{"record":{"id":"8b32cc0e149a601f","repo":"alibaba/nacos","slug":"param-servicename-is-illegal-groupname-can-t-be","errorCode":null,"errorMessage":"Param 'serviceName' is illegal, groupName can't be empty","messagePattern":"Param 'serviceName' is illegal, groupName can't be empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/com/alibaba/nacos/api/naming/utils/NamingUtils.java","lineNumber":140,"sourceCode":"    /**\n     * check combineServiceName format. the serviceName can't be blank.\n     * <pre>\n     * serviceName = \"@@\";                 the length = 0; illegal\n     * serviceName = \"group@@\";            the length = 1; illegal\n     * serviceName = \"@@serviceName\";      the length = 2; illegal\n     * serviceName = \"group@@serviceName\"; the length = 2; legal\n     * </pre>\n     *\n     * @param combineServiceName such as: groupName@@serviceName\n     */\n    public static void checkServiceNameFormat(String combineServiceName) {\n        String[] split = combineServiceName.split(Constants.SERVICE_INFO_SPLITER);\n        if (split.length <= 1) {\n            throw new IllegalArgumentException(\n                \"Param 'serviceName' is illegal, it should be format as 'groupName@@serviceName'\");\n        }\n        if (split[0].isEmpty()) {\n            throw new IllegalArgumentException(\n                \"Param 'serviceName' is illegal, groupName can't be empty\");\n        }\n    }\n    \n    /**\n     * Returns a combined string with serviceName and groupName. Such as 'groupName@@serviceName'\n     * <p>This method works similar with {@link com.alibaba.nacos.api.naming.utils.NamingUtils#getGroupedName} But not\n     * verify any parameters.\n     *\n     * </p> etc:\n     * <p>serviceName | groupName | result</p>\n     * <p>serviceA    | groupA    | groupA@@serviceA</p>\n     * <p>nil         | groupA    | groupA@@</p>\n     * <p>nil         | nil       | @@</p>\n     *\n     * @return 'groupName@@serviceName'\n     */\n    public static String getGroupedNameOptional(final String serviceName, final String groupName) {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/api/src/main/java/com/alibaba/nacos/api/naming/utils/NamingUtils.java#L122-L158","documentation":"Second guard inside checkServiceNameFormat: even when '@@' is present, the groupName segment (split[0]) must not be empty. This rejects inputs like '@@serviceName' that look formatted but are missing the group.","triggerScenarios":"checkServiceNameFormat(\"@@my-service\"); a corrupted key where the group prefix was stripped.","commonSituations":"String manipulation that trimmed the group; concatenated key with a null/blank group variable on the left of '@@'.","solutions":["Ensure a non-empty group segment before the '@@'.","Construct the combined name via NamingUtils.getGroupedName so groupName is validated first."],"exampleFix":"// before\nNamingUtils.checkServiceNameFormat(\"@@my-service\");  // throws 545\n\n// after\nNamingUtils.checkServiceNameFormat(\"DEFAULT_GROUP@@my-service\");","handlingStrategy":"validation","validationCode":"if (combineServiceName == null || combineServiceName.isEmpty()\n        || combineServiceName.startsWith(Constants.SERVICE_INFO_SPLITER)) {\n    throw new IllegalArgumentException(\"group segment must not be empty\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never concatenate '@@' with a null/blank left-hand variable.","Unit-test key builders with blank group inputs."],"tags":["naming","validation","service-key","format"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}