{"record":{"id":"d9316a71145baf47","repo":"apolloconfig/apollo","slug":"namespace-appid-s-cluster-s-nowcount-s-m","errorCode":null,"errorMessage":"namespace[appId = %s, cluster= %s] nowCount= %s, maxCount =%s","messagePattern":"namespace\\[appId = (.+?), cluster= (.+?)\\] nowCount= (.+?), maxCount =(.+?)","errorType":"exception","errorClass":"ServiceException","httpStatus":500,"severity":"error","filePath":"apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java","lineNumber":367,"sourceCode":"    messageSender.sendMessage(\n        ReleaseMessageKeyGenerator.generate(appId, clusterName, namespaceName),\n        Topics.APOLLO_RELEASE_TOPIC);\n\n    return deleted;\n  }\n\n  @Transactional\n  public Namespace save(Namespace entity) {\n    if (!isNamespaceUnique(entity.getAppId(), entity.getClusterName(), entity.getNamespaceName())) {\n      throw new ServiceException(\"namespace not unique\");\n    }\n\n    if (bizConfig.isNamespaceNumLimitEnabled()\n        && !bizConfig.namespaceNumLimitWhite().contains(entity.getAppId())) {\n      int nowCount = namespaceRepository.countByAppIdAndClusterName(entity.getAppId(),\n          entity.getClusterName());\n      if (nowCount >= bizConfig.namespaceNumLimit()) {\n        throw new ServiceException(\n            \"namespace[appId = \" + entity.getAppId() + \", cluster= \" + entity.getClusterName()\n                + \"] nowCount= \" + nowCount + \", maxCount =\" + bizConfig.namespaceNumLimit());\n      }\n    }\n\n    entity.setId(0);// protection\n    Namespace namespace = namespaceRepository.save(entity);\n\n    auditService.audit(Namespace.class.getSimpleName(), namespace.getId(), Audit.OP.INSERT,\n        namespace.getDataChangeCreatedBy());\n\n    return namespace;\n  }\n\n  @Transactional\n  public Namespace update(Namespace namespace) {\n    Namespace managedNamespace = namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(\n        namespace.getAppId(), namespace.getClusterName(), namespace.getNamespaceName());","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java#L349-L385","documentation":"Thrown as ServiceException (HTTP 500) by NamespaceService.save when namespace.num.limit.enabled is true, the appId is not in the namespace.num.limit.white whitelist, and the current namespace count for that (appId, clusterName) already meets namespace.num.limit. This caps how many namespaces a cluster can hold.","triggerScenarios":"Creating a new namespace in a cluster whose namespace count is already >= the configured namespace.num.limit, for an appId that is not whitelisted.","commonSituations":"Tenant/multi-team clusters hitting the namespace cap; envs where ops set a low namespace limit; automated pipelines creating many namespaces.","solutions":["Raise namespace.num.limit for the deployment, or add the appId to namespace.num.limit.white.","Re-use existing namespaces or consolidate config instead of adding new ones.","Move work into a different cluster that has headroom."],"exampleFix":"# portal admin config\nnamespace.num.limit.enabled = true\nnamespace.num.limit = 200\nnamespace.num.limit.white = specialApp1,specialApp2","handlingStrategy":"validation","validationCode":"if (bizConfig.isNamespaceNumLimitEnabled()\n    && !bizConfig.namespaceNumLimitWhite().contains(appId)) {\n  int now = namespaceRepository.countByAppIdAndClusterName(appId, clusterName);\n  if (now >= bizConfig.namespaceNumLimit()) {\n    // do not call save; raise limit / whitelist / use another cluster\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  namespaceService.save(entity);\n} catch (ServiceException e) {\n  if (e.getMessage().contains(\"maxCount\")) { /* quota handling */ }\n  else throw e;\n}","preventionTips":["Track namespace counts per cluster against the configured cap.","Pre-flight new namespaces against namespace.num.limit before save.","Keep an allowlist for high-volume apps in namespace.num.limit.white."],"tags":["namespace","limit","service-error","apollo-biz","quota"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}