apolloconfig/apollo · error · BadRequestException
value too long. length limit:%s
Error message
value too long. length limit:%s
What it means
A BadRequestException (HTTP 400) thrown from ItemService.checkItemValueLength() when an item's value exceeds the configured length limit. The limit is determined by getItemValueLengthLimit(): per-namespace override > per-appId override > global default (DEFAULT_ITEM_VALUE_LENGTH = 20000). For gray-release namespaces (cluster name matching pattern [0-9]{14}-[a-zA-Z0-9]{16}), the limit may be raised to the parent namespace's limit if it is larger.
Source
Thrown at apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java:234
auditService.audit(Item.class.getSimpleName(), managedItem.getId(), Audit.OP.UPDATE,
managedItem.getDataChangeLastModifiedBy());
return managedItem;
}
private boolean checkItemValueLength(long namespaceId, String value) {
Namespace currentNamespace = namespaceService.findOne(namespaceId);
int limit = getItemValueLengthLimit(currentNamespace);
if (currentNamespace != null) {
Matcher m = clusterPattern.matcher(currentNamespace.getClusterName());
boolean isGray = m.matches();
if (isGray) {
limit = getGrayNamespaceItemValueLengthLimit(currentNamespace, limit);
}
}
if (!StringUtils.isEmpty(value) && value.length() > limit) {
throw new BadRequestException("value too long. length limit:" + limit);
}
return true;
}
private int getGrayNamespaceItemValueLengthLimit(Namespace grayNamespace,
int grayNamespaceLimit) {
Namespace parentNamespace = namespaceService.findParentNamespace(grayNamespace);
if (parentNamespace != null) {
int parentLimit = getItemValueLengthLimit(parentNamespace);
if (parentLimit > grayNamespaceLimit) {
return parentLimit;
}
}
return grayNamespaceLimit;
}
private boolean checkItemKeyLength(String key) {
if (!StringUtils.isEmpty(key) && key.length() > bizConfig.itemKeyLengthLimit()) {View on GitHub (pinned to d95fc18d11)
Solutions
- Shorten the value to be within the limit, or store large data externally and reference it by URL/key in Apollo.
- Increase the limit via biz config key 'item.value.length.limit' (minimum 5).
- Set a per-appId override via 'appid.value.length.limit.override' (JSON: {"appId": limit}) or per-namespace via 'namespace.value.length.limit.override' (JSON: {"namespaceId": limit}).
- For gray namespaces, ensure the parent namespace has a sufficiently large limit so the gray limit inherits it.
Example fix
// before: storing a huge value directly
item.setValue(hugeCertificatePem); // > 20000 chars -> rejected
// after option 1: reference externally
item.setValue("s3://config-bucket/cert.pem");
// after option 2: increase limit in biz config
// System Settings: item.value.length.limit = 50000 Defensive patterns
Strategy: validation
Validate before calling
// Check value length against the configured limit before saving
int limit = bizConfig.itemValueLengthLimit(); // default 20000
if (!StringUtils.isEmpty(value) && value.length() > limit) {
// truncate, externalize, or increase limit before proceeding
throw new IllegalArgumentException("Value exceeds limit of " + limit);
}
item.setValue(value);
itemService.save(item); Prevention
- Validate value length client-side against the configured limit before sending.
- Store large blobs externally and reference them by URL in Apollo.
- Set appropriate per-appId or per-namespace value-length overrides if specific namespaces need larger values.
- Monitor biz config for changes to item.value.length.limit.
When it happens
Trigger: ItemService.save() or update() is called with a value whose length exceeds the resolved limit. The check fires for non-empty values only. Config keys involved: item.value.length.limit (default 20000), appid.value.length.limit.override (JSON map), namespace.value.length.limit.override (JSON map).
Common situations: Storing a large blob, certificate, or long JSON string as a config value that exceeds 20000 characters; the global limit was lowered via config after large values were already present; a migration importing values that exceed the limit.
Related errors
- key too long. length limit:%s
- The maximum number of items (%s) for this namespace has been
- type is invalid. type should be in [0, 3].
- Comment item's key or value should be blank.
- Comment item's comment should not be blank.
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/838aa8282be33c60.
Report an issue: GitHub.