apolloconfig/apollo · error · BadRequestException

The maximum number of items (%s) for this namespace has been

Error message

The maximum number of items (%s) for this namespace has been reached. Current item count is %s.

What it means

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.

Source

Thrown at apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java:89

    this.bizConfig = bizConfig;
  }

  @PreAcquireNamespaceLock
  @PostMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items")
  public ItemDTO create(@PathVariable("appId") String appId,
      @PathVariable("clusterName") String clusterName,
      @PathVariable("namespaceName") String namespaceName, @RequestBody ItemDTO dto) {
    Item entity = BeanUtils.transform(Item.class, dto);

    Item managedEntity = itemService.findOne(appId, clusterName, namespaceName, entity.getKey());
    if (managedEntity != null) {
      throw BadRequestException.itemAlreadyExists(entity.getKey());
    }

    if (bizConfig.isItemNumLimitEnabled()) {
      int itemCount = itemService.findNonEmptyItemCount(entity.getNamespaceId());
      if (itemCount >= bizConfig.itemNumLimit()) {
        throw new BadRequestException("The maximum number of items (" + bizConfig.itemNumLimit()
            + ") for this namespace has been reached. Current item count is " + itemCount + ".");
      }
    }

    entity = itemService.save(entity);
    dto = BeanUtils.transform(ItemDTO.class, entity);
    commitService.createCommit(appId, clusterName, namespaceName,
        new ConfigChangeContentBuilder().createItem(entity).build(),
        dto.getDataChangeLastModifiedBy());

    return dto;
  }

  @PostMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/comment_items")
  public ItemDTO createComment(@PathVariable("appId") String appId,
      @PathVariable("clusterName") String clusterName,
      @PathVariable("namespaceName") String namespaceName, @RequestBody ItemDTO dto) {
    if (!StringUtils.isBlank(dto.getKey()) || !StringUtils.isBlank(dto.getValue())) {

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Remove or consolidate unused items in the namespace to get below the limit.
  2. Increase the limit by setting 'item.num.limit' to a higher value in the apollo biz config (apollo-portal system settings), minimum 5.
  3. If the limit feature is not needed, set 'item.num.limit.enabled' to false.
  4. Split the configuration across multiple namespaces if a single namespace genuinely needs more entries.

Example fix

// before: blindly create items in a loop
for (ItemDTO item : items) {
    openApi.createItem(appId, env, cluster, namespace, item);
}

// after: check count first and handle the limit
OpenItemService itemApi = openApi.createOpenItemService();
// increase limit in portal: System Settings > item.num.limit = 5000
// or split data across namespaces if genuinely large
Defensive patterns

Strategy: validation

Validate before calling

// Check current item count before creating
List<ItemDTO> items = openApi.findItems(appId, env, cluster, namespace);
long nonEmptyCount = items.stream().filter(i -> StringUtils.isNotBlank(i.getKey())).count();
if (nonEmptyCount >= itemLimit) {
    // clean up or increase limit before proceeding
    cleanupOrSplitNamespace(items);
} else {
    openApi.createItem(appId, env, cluster, namespace, newItem);
}

Prevention

When it happens

Trigger: 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'.

Common situations: 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.

Related errors


AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14). Data as JSON: /api/errors/5bead1ae7d7fb277. Report an issue: GitHub.