{"record":{"id":"f5d335aae352805e","repo":"alibaba/nacos","slug":"400-f5d335","errorCode":"400","errorMessage":"service not found groupName: %s,serviceName: %s","messagePattern":"service not found groupName: (.+?),serviceName: (.+?)","errorType":"validation","errorClass":"NacosException","httpStatus":null,"severity":"error","filePath":"naming/src/main/java/com/alibaba/nacos/naming/core/ClusterOperatorV2Impl.java","lineNumber":58,"sourceCode":"    }\n    \n    @Override\n    public void updateClusterMetadata(String namespaceId, String serviceName, String clusterName,\n        ClusterMetadata clusterMetadata) throws NacosException {\n        String groupName = NamingUtils.getGroupName(serviceName);\n        String serviceNameWithoutGroup = NamingUtils.getServiceName(serviceName);\n        updateClusterMetadata(namespaceId, groupName, serviceNameWithoutGroup, clusterName,\n            clusterMetadata);\n    }\n    \n    @Override\n    public void updateClusterMetadata(String namespaceId, String groupName, String serviceName,\n        String clusterName,\n        ClusterMetadata clusterMetadata) throws NacosException {\n        Optional<Service> service = ServiceManager.getInstance()\n            .getSingletonIfExist(namespaceId, groupName, serviceName);\n        if (service.isEmpty()) {\n            throw new NacosException(NacosException.INVALID_PARAM,\n                String.format(\"service not found groupName: %s,serviceName: %s\", groupName,\n                    serviceName));\n        }\n        metadataOperateService.addClusterMetadata(service.get(), clusterName, clusterMetadata);\n    }\n}\n","sourceCodeStart":40,"sourceCodeEnd":65,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/naming/src/main/java/com/alibaba/nacos/naming/core/ClusterOperatorV2Impl.java#L40-L65","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Create/register the service first, then update cluster metadata.","Verify the service exists in the specified namespace and group.","Retry if the service creation is in progress (eventual consistency).","Check for typos in groupName and serviceName."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Optional<Service> svc = ServiceManager.getInstance()\n    .getSingletonIfExist(namespaceId, groupName, serviceName);\nif (svc.isEmpty()) {\n    throw new IllegalStateException(\n        \"Cannot update cluster metadata: service \" + groupName + \"/\" + serviceName + \" not found\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    clusterOperator.updateClusterMetadata(namespaceId, groupName, serviceName, clusterName, metadata);\n} catch (NacosException e) {\n    if (e.getErrCode() == NacosException.INVALID_PARAM\n            && e.getMessage().contains(\"service not found\")) {\n        // register the service first, then retry\n    } else { throw e; }\n}","preventionTips":["Create/register the service before attaching cluster metadata.","Verify the service exists in the correct namespace and group before cluster operations.","Handle the race between service creation and cluster metadata updates with a retry."],"tags":["naming","not-found","cluster","metadata","admin-api"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}