apolloconfig/apollo · error · BadRequestException
Comment item's comment should not be blank.
Error message
Comment item's comment should not be blank.
What it means
A BadRequestException (HTTP 400) thrown from ItemController.createComment() (POST .../comment_items) when the comment field is blank. After validating that key and value are blank (error [5]), this check ensures the comment itself has content — a comment item with no comment text is meaningless. The validation is: StringUtils.isBlank(dto.getComment()).
Source
Thrown at apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java:111
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())) {
throw new BadRequestException("Comment item's key or value should be blank.");
}
if (StringUtils.isBlank(dto.getComment())) {
throw new BadRequestException("Comment item's comment should not be blank.");
}
// check if comment existed
List<Item> allItems = itemService.findItemsWithOrdered(appId, clusterName, namespaceName);
for (Item item : allItems) {
if (StringUtils.isBlank(item.getKey()) && StringUtils.isBlank(item.getValue())
&& Objects.equals(item.getComment(), dto.getComment())) {
return BeanUtils.transform(ItemDTO.class, item);
}
}
Item entity = BeanUtils.transform(Item.class, dto);
entity = itemService.saveComment(entity);
return BeanUtils.transform(ItemDTO.class, entity);
}
View on GitHub (pinned to d95fc18d11)
Solutions
- Provide a non-blank comment string in the request body.
- Add client-side validation to require the comment field before calling the endpoint.
- Skip the API call entirely if the comment is blank, since the server will reject it.
Example fix
// before: empty comment
ItemDTO dto = new ItemDTO();
dto.setKey("");
dto.setValue("");
dto.setComment(""); // blank -> rejected
openApi.createCommentItem(appId, env, cluster, namespace, dto);
// after: validate before calling
if (StringUtils.isNotBlank(commentText)) {
dto.setComment(commentText);
openApi.createCommentItem(appId, env, cluster, namespace, dto);
} Defensive patterns
Strategy: validation
Validate before calling
// Validate comment is non-blank before calling
if (StringUtils.isBlank(dto.getComment())) {
throw new IllegalArgumentException("Comment text is required");
}
openApi.createCommentItem(appId, env, cluster, namespace, dto); Prevention
- Add client-side validation requiring the comment field before calling the endpoint.
- Skip the API call if the comment is blank rather than letting the server reject it.
- Initialize the comment field from validated user input.
When it happens
Trigger: POST .../comment_items with a JSON body where the comment field is null, empty, or whitespace-only, e.g. {"key":"","value":"","comment":""} or {"key":"","value":"","comment":" "}.
Common situations: Client sends an empty comment by mistake; a form submission where the comment field was left blank; programmatic creation where the comment variable was uninitialized.
Related errors
- Comment item's key or value should be blank.
- The App Id of path variable and request body is different
- The maximum number of items (%s) for this namespace has been
- value too long. length limit:%s
- key too long. length limit:%s
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/419597a801943c8d.
Report an issue: GitHub.