halo-dev/halo · warning · ServerWebInputException
The required parameter 'commentName' is missing.
Error message
The required parameter 'commentName' is missing.
What it means
ReplyQuery.getCommentName() reads the commentName query parameter used to scope a reply listing. It throws ServerWebInputException (HTTP 400) when the parameter is missing or blank. The same value is reused in toListOptions() to build the field selector, so a blank commentName would produce an ambiguous query — hence the early guard.
Source
Thrown at application/src/main/java/run/halo/app/content/comment/ReplyQuery.java:35
import run.halo.app.extension.router.SortableRequest;
/**
* Query criteria for {@link Reply} list.
*
* @author guqing
* @since 2.0.0
*/
public class ReplyQuery extends SortableRequest {
public ReplyQuery(ServerWebExchange exchange) {
super(exchange);
}
/** Metadata name of the comment whose replies should be listed. */
public String getCommentName() {
String commentName = queryParams.getFirst("commentName");
if (StringUtils.isBlank(commentName)) {
throw new ServerWebInputException("The required parameter 'commentName' is missing.");
}
return commentName;
}
/** Build list options from query criteria. */
public ListOptions toListOptions() {
var listOptions = labelAndFieldSelectorToListOptions(getLabelSelector(), getFieldSelector());
var newFieldSelector = listOptions.getFieldSelector().andQuery(equal("spec.commentName", getCommentName()));
listOptions.setFieldSelector(newFieldSelector);
return listOptions;
}
public PageRequest toPageRequest() {
var sort = getSort().and(Sort.by("spec.creationTime").ascending());
return PageRequestImpl.of(getPage(), getSize(), sort);
}
public static void buildParameters(Builder builder) {View on GitHub (pinned to d2f5165f9c)
Solutions
- Always include ?commentName=<comment metadata name> on the replies request.
- On the client, assert commentName is present before issuing the request.
- If listing all replies is genuinely needed, use a different endpoint that supports an unscoped query rather than dropping the parameter.
Example fix
// before
fetch('/apis/api.console.halo.run/v1alpha1/commenters/replies') // 400
// after
fetch(`/apis/api.console.halo.run/v1alpha1/commenters/replies?commentName=${encodeURIComponent(commentName)}`) Defensive patterns
Strategy: validation
Validate before calling
String commentName = exchange.getRequest().getQueryParams().getFirst("commentName");
if (!StringUtils.hasText(commentName)) {
return Mono.error(new ServerWebInputException("commentName required"));
}
new ReplyQuery(exchange).toListOptions(); Type guard
static boolean hasCommentName(ServerWebExchange ex) {
return StringUtils.hasText(
ex.getRequest().getQueryParams().getFirst("commentName"));
} Prevention
- Always attach ?commentName=<name> when requesting replies.
- On the frontend, require a selected comment before loading its replies.
- Unit-test reply listing code with the parameter present.
When it happens
Trigger: GET request to the replies listing endpoint without a commentName query param, or with commentName=& (empty), or with only whitespace. Calling getCommentName() twice-free in custom code that forgets to pass the param.
Common situations: Frontend bug dropping the commentName query string when navigating/paginating replies; a client constructing the URL programmatically and omitting the parameter; theme code linking to the reply endpoint without the comment reference.
Related errors
- The kind must not be null.
- The name must not be null.
- urls must not be empty.
- Required url is missing.
- Policy name must not be blank
AI-assisted analysis of halo-dev/halo@d2f5165f9c (2026-08-14).
Data as JSON: /api/errors/733789e6a7e6247c.
Report an issue: GitHub.