alibaba/nacos · error · NacosApiException

22002

22002

Error message

namespaceId [{}] already exist.

What it means

Error "namespaceId [{}] already exist." thrown in alibaba/nacos.

Source

Thrown at core/src/main/java/com/alibaba/nacos/core/service/NamespaceOperationService.java:196

        try {
            if (NamespaceUtil.isDefaultNamespaceId(namespaceId)) {
                return true;
            }
            return namespacePersistService.tenantInfoCountByTenantId(namespaceId) > 0;
        } catch (Exception e) {
            Loggers.CORE.error(
                "Namespace validation query db error for namespace: {}, exception: {}", namespaceId,
                e);
            return false;
        }
    }
    
    /**
     * validate namespace not exists.
     */
    public void validateNamespaceNotExists(String namespaceId) throws NacosApiException {
        if (namespaceExists(namespaceId)) {
            throw new NacosApiException(HttpStatus.BAD_REQUEST.value(),
                ErrorCode.NAMESPACE_ALREADY_EXIST,
                "namespaceId [" + namespaceId + "] already exist.");
        }
    }
}

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Choose a different identifier or update the existing resource instead of creating it again.

When it happens

Trigger: Thrown at core/src/main/java/com/alibaba/nacos/core/service/NamespaceOperationService.java:196 when the library encounters an invalid state.

Common situations: Creating a namespace with an id that already exists.


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