alibaba/nacos · error · IllegalArgumentException

Param 'serviceName' is illegal, serviceName is blank

Error message

Param 'serviceName' is illegal, serviceName is blank

What it means

NamingUtils.getGroupedName composes the canonical 'group@@service' identifier and refuses a blank serviceName up front. The composite key would be ambiguous without it, so the method fails fast with IllegalArgumentException.

Source

Thrown at api/src/main/java/com/alibaba/nacos/api/naming/utils/NamingUtils.java:63

    
    private static final Pattern NUMBER_PATTERN = Pattern.compile(NUMBER_PATTERN_STRING);
    
    /**
     * Returns a combined string with serviceName and groupName. serviceName can not be nil.
     *
     * <p>In most cases, serviceName can not be nil. In other cases, for search or anything, See {@link
     * com.alibaba.nacos.api.naming.utils.NamingUtils#getGroupedNameOptional(String, String)}
     *
     * <p>etc:
     * <p>serviceName | groupName | result</p>
     * <p>serviceA    | groupA    | groupA@@serviceA</p>
     * <p>nil         | groupA    | threw IllegalArgumentException</p>
     *
     * @return 'groupName@@serviceName'
     */
    public static String getGroupedName(final String serviceName, final String groupName) {
        if (StringUtils.isBlank(serviceName)) {
            throw new IllegalArgumentException(
                "Param 'serviceName' is illegal, serviceName is blank");
        }
        if (StringUtils.isBlank(groupName)) {
            throw new IllegalArgumentException("Param 'groupName' is illegal, groupName is blank");
        }
        final String resultGroupedName = groupName + Constants.SERVICE_INFO_SPLITER + serviceName;
        return resultGroupedName.intern();
    }
    
    public static String getServiceKey(String namespace, String group, String serviceName) {
        if (StringUtils.isBlank(namespace)) {
            namespace = DEFAULT_NAMESPACE_ID;
        }
        return namespace + Constants.SERVICE_INFO_SPLITER + group + Constants.SERVICE_INFO_SPLITER
            + serviceName;
    }
    
    /**

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Provide a non-blank serviceName.
  2. Validate serviceName at the entry point (form/controller) before composing the grouped name.

Example fix

// before
String key = NamingUtils.getGroupedName(userInput, "DEFAULT_GROUP");  // userInput=="" throws 542

// after
if (StringUtils.isBlank(userInput)) throw new IllegalArgumentException("serviceName required");
String key = NamingUtils.getGroupedName(userInput, "DEFAULT_GROUP");
Defensive patterns

Strategy: validation

Validate before calling

if (StringUtils.isBlank(serviceName)) {
    throw new IllegalArgumentException("serviceName is required before composing grouped name");
}

Prevention

When it happens

Trigger: Calling getGroupedName("", "DEFAULT_GROUP"), getGroupedName(null, group), or with a whitespace-only serviceName.

Common situations: Client registerInstance invoked with an empty serviceName form field; building a key from a config value that resolved to blank.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/fa72272750b976bf. Report an issue: GitHub.