alibaba/nacos · error · IllegalArgumentException

Can't parse out 'groupName',but it must not be null!

Error message

Can't parse out 'groupName',but it must not be null!

What it means

ServiceInfo(String key) splits a composite key by '@@'. It needs at least GROUP_POSITION and SERVICE_POSITION parts to recover groupName and name. If the split yields fewer parts than CLUSTER_POSITION (defensive branch), it throws IllegalArgumentException because groupName cannot be safely derived.

Source

Thrown at api/src/main/java/com/alibaba/nacos/api/naming/pojo/ServiceInfo.java:102

        this.allIps = allIps;
    }
    
    /**
     * There is only one form of the key:groupName@@name@@clusters. This constructor used by DiskCache.read(String) and
     * FailoverReactor.FailoverFileReader,you should know that 'groupName' must not be null,and 'clusters' can be null.
     */
    public ServiceInfo(final String key) {
        String[] keys = key.split(Constants.SERVICE_INFO_SPLITER);
        if (keys.length >= FILE_NAME_PARTS) {
            this.groupName = keys[GROUP_POSITION];
            this.name = keys[SERVICE_POSITION];
            this.clusters = keys[CLUSTER_POSITION];
        } else if (keys.length == CLUSTER_POSITION) {
            this.groupName = keys[GROUP_POSITION];
            this.name = keys[SERVICE_POSITION];
        } else {
            //defensive programming
            throw new IllegalArgumentException(
                "Can't parse out 'groupName',but it must not be null!");
        }
    }
    
    public ServiceInfo(String name, String clusters) {
        this.name = name;
        this.clusters = clusters;
    }
    
    public int ipCount() {
        return hosts.size();
    }
    
    public boolean expired() {
        return System.currentTimeMillis() - lastRefTime > cacheMillis;
    }
    
    public void setHosts(List<Instance> hosts) {

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Pass a key in the form 'group@@name' or 'group@@name@@clusters'.
  2. Use the ServiceInfo(name, clusters) constructor when you only have a plain name.
  3. Build keys via NamingUtils.getServiceKey(...) / getGroupedName(...) rather than hand-concatenating.

Example fix

// before
ServiceInfo info = new ServiceInfo("my-service");  // throws 541

// after
ServiceInfo info = new ServiceInfo("DEFAULT_GROUP@@my-service@@DEFAULT");
Defensive patterns

Strategy: validation

Validate before calling

String[] parts = key.split(Constants.SERVICE_INFO_SPLITER);
if (parts.length < 2) {
    throw new IllegalArgumentException("key must be at least 'group@@name'");
}

Try / catch

try {
    return new ServiceInfo(key);
} catch (IllegalArgumentException e) {
    // rebuild a valid key from explicit group + name
    return new ServiceInfo(NamingUtils.getGroupedName(name, group), clusters);
}

Prevention

When it happens

Trigger: Constructing new ServiceInfo("my-service") with a bare name; reading a corrupted cache filename that lost its '@@' separators; passing a plain serviceName where a grouped key is expected.

Common situations: Service-info cache file rebuilt incorrectly after a version change; client code confusing serviceName with the composite key; manually crafted keys missing the group segment.

Related errors


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