{"record":{"id":"3f31ecf610b9ed65","repo":"alibaba/nacos","slug":"service-not-exist","errorCode":"SERVICE_NOT_EXIST","errorMessage":"service %s is not exist.","messagePattern":"service (.+?) is not exist\\.","errorType":"http","errorClass":"NacosApiException","httpStatus":404,"severity":"warning","filePath":"console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/naming/ServiceInnerHandler.java","lineNumber":105,"sourceCode":"    @Override\n    public void deleteService(String namespaceId, String serviceName, String groupName)\n        throws Exception {\n        serviceOperatorV2.delete(\n            com.alibaba.nacos.naming.core.v2.pojo.Service.newService(namespaceId, groupName,\n                serviceName));\n        NotifyCenter.publishEvent(\n            new DeregisterServiceTraceEvent(System.currentTimeMillis(), namespaceId, groupName,\n                serviceName));\n    }\n    \n    @Override\n    public void updateService(ServiceForm serviceForm, ServiceMetadata serviceMetadata)\n        throws Exception {\n        Service service =\n            Service.newService(serviceForm.getNamespaceId(), serviceForm.getGroupName(),\n                serviceForm.getServiceName());\n        if (!ServiceManager.getInstance().containSingleton(service)) {\n            throw new NacosApiException(NacosException.NOT_FOUND, ErrorCode.SERVICE_NOT_EXIST,\n                \"service %s is not exist.\".formatted(service.toString()));\n        }\n        service = ServiceManager.getInstance().getSingleton(service);\n        serviceOperatorV2.update(service, serviceMetadata);\n        NotifyCenter.publishEvent(\n            new UpdateServiceTraceEvent(System.currentTimeMillis(), serviceForm.getNamespaceId(),\n                serviceForm.getGroupName(), serviceForm.getServiceName(),\n                serviceMetadata.getExtendData()));\n    }\n    \n    @Override\n    public List<String> getSelectorTypeList() throws NacosException {\n        return selectorManager.getAllSelectorTypes();\n    }\n    \n    @Override\n    public Page<SubscriberInfo> getSubscribers(int pageNo, int pageSize, String namespaceId,\n        String serviceName,","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/naming/ServiceInnerHandler.java#L87-L123","documentation":"Thrown by ServiceInnerHandler.updateService when the target service is not present in the ServiceManager singleton for the given namespace/group/serviceName. It raises NacosApiException with NacosException.NOT_FOUND (HTTP 404) and ErrorCode.SERVICE_NOT_EXIST. The update only applies to an existing service.","triggerScenarios":"Calling the service-update API for a service that has never been registered, was deleted, or whose namespace/group/serviceName does not match any singleton.","commonSituations":"Updating a service in the wrong namespace; service was removed between list and update; mistyped group or serviceName; persistent service never created.","solutions":["Verify the service exists in the exact namespaceId/groupName/serviceName before updating (query the service list/detail).","If the service does not exist, create it first via the create-service API.","Double-check namespace, group, and service name spelling/casing."],"exampleFix":"// before\nhandler.updateService(form, metadata); // service does not exist\n\n// after\nService key = Service.newService(ns, group, serviceName);\nif (!ServiceManager.getInstance().containSingleton(key)) {\n    handler.createService(form); // create first\n}\nhandler.updateService(form, metadata);","handlingStrategy":"validation","validationCode":"// Verify the service exists before updating it\nService key = Service.newService(form.getNamespaceId(), form.getGroupName(), form.getServiceName());\nif (!ServiceManager.getInstance().containSingleton(key)) {\n    throw new NoSuchResourceException(\"service not found: \" + key);\n}\nhandler.updateService(form, metadata);","typeGuard":"// Java: boolean guard that the service singleton exists\nboolean serviceExists = ServiceManager.getInstance()\n    .containSingleton(Service.newService(ns, group, serviceName));","tryCatchPattern":"try {\n    handler.updateService(form, metadata);\n} catch (NacosApiException e) {\n    if (e.getErrCode() == NacosException.NOT_FOUND) {\n        handler.createService(form); // create then retry update\n        handler.updateService(form, metadata);\n    } else { throw e; }\n}","preventionTips":["Check service existence in the exact namespace/group/serviceName before updating.","Create the service first if it does not exist.","Re-fetch the service list right before an update to avoid race with deletes."],"tags":["naming","service","not-found","console"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}