{"record":{"id":"5bead1ae7d7fb277","repo":"apolloconfig/apollo","slug":"the-maximum-number-of-items-s-for-this-namespac","errorCode":null,"errorMessage":"The maximum number of items (%s) for this namespace has been reached. Current item count is %s.","messagePattern":"The maximum number of items \\((.+?)\\) for this namespace has been reached\\. Current item count is (.+?)\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java","lineNumber":89,"sourceCode":"    this.bizConfig = bizConfig;\n  }\n\n  @PreAcquireNamespaceLock\n  @PostMapping(\"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items\")\n  public ItemDTO create(@PathVariable(\"appId\") String appId,\n      @PathVariable(\"clusterName\") String clusterName,\n      @PathVariable(\"namespaceName\") String namespaceName, @RequestBody ItemDTO dto) {\n    Item entity = BeanUtils.transform(Item.class, dto);\n\n    Item managedEntity = itemService.findOne(appId, clusterName, namespaceName, entity.getKey());\n    if (managedEntity != null) {\n      throw BadRequestException.itemAlreadyExists(entity.getKey());\n    }\n\n    if (bizConfig.isItemNumLimitEnabled()) {\n      int itemCount = itemService.findNonEmptyItemCount(entity.getNamespaceId());\n      if (itemCount >= bizConfig.itemNumLimit()) {\n        throw new BadRequestException(\"The maximum number of items (\" + bizConfig.itemNumLimit()\n            + \") for this namespace has been reached. Current item count is \" + itemCount + \".\");\n      }\n    }\n\n    entity = itemService.save(entity);\n    dto = BeanUtils.transform(ItemDTO.class, entity);\n    commitService.createCommit(appId, clusterName, namespaceName,\n        new ConfigChangeContentBuilder().createItem(entity).build(),\n        dto.getDataChangeLastModifiedBy());\n\n    return dto;\n  }\n\n  @PostMapping(\"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/comment_items\")\n  public ItemDTO createComment(@PathVariable(\"appId\") String appId,\n      @PathVariable(\"clusterName\") String clusterName,\n      @PathVariable(\"namespaceName\") String namespaceName, @RequestBody ItemDTO dto) {\n    if (!StringUtils.isBlank(dto.getKey()) || !StringUtils.isBlank(dto.getValue())) {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java#L71-L107","documentation":"A BadRequestException (HTTP 400) thrown from ItemController.create() (POST .../items) when item.num.limit.enabled is true in biz config and the count of non-empty items in the target namespace has reached or exceeded the configured limit (bizConfig.itemNumLimit(), default 1000). This is a capacity guard to keep namespaces manageable and prevent unbounded growth.","triggerScenarios":"POST /apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items when bizConfig.isItemNumLimitEnabled() returns true and itemService.findNonEmptyItemCount(namespaceId) >= bizConfig.itemNumLimit(). The limit defaults to 1000 (DEFAULT_MAX_ITEM_NUM) but can be overridden via the apollo biz config key 'item.num.limit'.","commonSituations":"A namespace accumulates many configuration keys over time and eventually hits the ceiling; a migration or bulk-import script tries to load more entries than the limit allows; the limit was lowered via config after items were already present.","solutions":["Remove or consolidate unused items in the namespace to get below the limit.","Increase the limit by setting 'item.num.limit' to a higher value in the apollo biz config (apollo-portal system settings), minimum 5.","If the limit feature is not needed, set 'item.num.limit.enabled' to false.","Split the configuration across multiple namespaces if a single namespace genuinely needs more entries."],"exampleFix":"// before: blindly create items in a loop\nfor (ItemDTO item : items) {\n    openApi.createItem(appId, env, cluster, namespace, item);\n}\n\n// after: check count first and handle the limit\nOpenItemService itemApi = openApi.createOpenItemService();\n// increase limit in portal: System Settings > item.num.limit = 5000\n// or split data across namespaces if genuinely large","handlingStrategy":"validation","validationCode":"// Check current item count before creating\nList<ItemDTO> items = openApi.findItems(appId, env, cluster, namespace);\nlong nonEmptyCount = items.stream().filter(i -> StringUtils.isNotBlank(i.getKey())).count();\nif (nonEmptyCount >= itemLimit) {\n    // clean up or increase limit before proceeding\n    cleanupOrSplitNamespace(items);\n} else {\n    openApi.createItem(appId, env, cluster, namespace, newItem);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Monitor item counts in large namespaces and clean up unused entries proactively.","Set 'item.num.limit' to an appropriate value for your workload in biz config.","Split very large configuration sets across multiple namespaces.","Disable 'item.num.limit.enabled' if the limit is not needed."],"tags":["item","limit","capacity","biz-config","bad-request","apollo-adminservice"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}