alibaba/nacos · error · NacosException

400

400

Error message

service not found groupName: %s,serviceName: %s

What it means

Thrown by ClusterOperatorV2Impl.updateClusterMetadata when the target service does not exist in the ServiceManager singleton registry. Uses INVALID_PARAM=400 (note: semantically a not-found but the code uses INVALID_PARAM). The method looks up the service via getSingletonIfExist(namespaceId, groupName, serviceName) and throws if the Optional is empty.

Source

Thrown at naming/src/main/java/com/alibaba/nacos/naming/core/ClusterOperatorV2Impl.java:58

    }
    
    @Override
    public void updateClusterMetadata(String namespaceId, String serviceName, String clusterName,
        ClusterMetadata clusterMetadata) throws NacosException {
        String groupName = NamingUtils.getGroupName(serviceName);
        String serviceNameWithoutGroup = NamingUtils.getServiceName(serviceName);
        updateClusterMetadata(namespaceId, groupName, serviceNameWithoutGroup, clusterName,
            clusterMetadata);
    }
    
    @Override
    public void updateClusterMetadata(String namespaceId, String groupName, String serviceName,
        String clusterName,
        ClusterMetadata clusterMetadata) throws NacosException {
        Optional<Service> service = ServiceManager.getInstance()
            .getSingletonIfExist(namespaceId, groupName, serviceName);
        if (service.isEmpty()) {
            throw new NacosException(NacosException.INVALID_PARAM,
                String.format("service not found groupName: %s,serviceName: %s", groupName,
                    serviceName));
        }
        metadataOperateService.addClusterMetadata(service.get(), clusterName, clusterMetadata);
    }
}

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Create/register the service first, then update cluster metadata.
  2. Verify the service exists in the specified namespace and group.
  3. Retry if the service creation is in progress (eventual consistency).
  4. Check for typos in groupName and serviceName.
Defensive patterns

Strategy: validation

Validate before calling

Optional<Service> svc = ServiceManager.getInstance()
    .getSingletonIfExist(namespaceId, groupName, serviceName);
if (svc.isEmpty()) {
    throw new IllegalStateException(
        "Cannot update cluster metadata: service " + groupName + "/" + serviceName + " not found");
}

Try / catch

try {
    clusterOperator.updateClusterMetadata(namespaceId, groupName, serviceName, clusterName, metadata);
} catch (NacosException e) {
    if (e.getErrCode() == NacosException.INVALID_PARAM
            && e.getMessage().contains("service not found")) {
        // register the service first, then retry
    } else { throw e; }
}

Prevention

When it happens

Trigger: Calling updateClusterMetadata or updateClusterMetadata(serviceName-with-group) for a service that has not been registered. The service must exist before cluster metadata can be attached.

Common situations: Attempting to update cluster metadata before the service is created. Service was deleted. Wrong namespace/group/service name. Race condition where the service is being created concurrently but is not yet visible.

Related errors


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