halo-dev/halo · error · ServerWebInputException
Name is required
Error message
Name is required
What it means
Thrown as a ServerWebInputException (HTTP 400) by UserEndpoint.createUser when createUserRequest.name() is blank (null, empty, or whitespace). Name is the user resource's metadata.name and is mandatory for user creation.
Source
Thrown at application/src/main/java/run/halo/app/core/endpoint/console/UserEndpoint.java:458
});
}
private Flux<DataBuffer> maxSizeCheck(Flux<DataBuffer> content) {
var lenRef = new AtomicInteger(0);
return content.doOnNext(dataBuffer -> {
int len = lenRef.accumulateAndGet(dataBuffer.readableByteCount(), Integer::sum);
if (len > MAX_AVATAR_FILE_SIZE.toBytes()) {
throw new ServerWebInputException(
"The avatar file needs to be smaller than " + MAX_AVATAR_FILE_SIZE.toMegabytes() + " MB.");
}
});
}
private Mono<ServerResponse> createUser(ServerRequest request) {
return request.bodyToMono(CreateUserRequest.class)
.doOnNext(createUserRequest -> {
if (StringUtils.isBlank(createUserRequest.name())) {
throw new ServerWebInputException("Name is required");
}
if (StringUtils.isBlank(createUserRequest.email())) {
throw new ServerWebInputException("Email is required");
}
})
.flatMap(userRequest -> {
User newUser = CreateUserRequest.from(userRequest);
var encryptedPwd = userService.encryptPassword(userRequest.password());
newUser.getSpec().setPassword(encryptedPwd);
return userService.createUser(newUser, userRequest.roles());
})
.flatMap(user -> ServerResponse.ok()
.contentType(MediaType.APPLICATION_JSON)
.bodyValue(user));
}
private Mono<ServerResponse> getUserByName(ServerRequest request) {
final var name = request.pathVariable("name");View on GitHub (pinned to d2f5165f9c)
Solutions
- Provide a non-blank 'name' (lowercase, DNS-subdomain-safe) in the create-user request body.
- Add client-side required-field validation on the username input.
- For programmatic creation, assert name is non-blank before constructing the payload.
Example fix
// before: { "email": "a@b.com", "password": "secret" }
// after: { "name": "alice", "email": "a@b.com", "password": "secret" } Defensive patterns
Strategy: validation
Validate before calling
// require a non-blank name before creating a user
if (StringUtils.isBlank(payload.name)) {
showUserError("Username is required");
return;
} Prevention
- Make the username field required in the admin UI.
- Use a lowercase DNS-subdomain-safe name pattern.
When it happens
Trigger: POST /apis/api.console.halo.run/v1alpha1/users (createUser) with a JSON body where 'name' is missing, null, empty string, or only whitespace.
Common situations: Admin form submitted before filling the username; API client omitted the name field; a script bulk-creates users from a CSV with a blank username column; refactor changed the field name expected by the client.
Related errors
- Email is required
- validation.error.email.pattern
- validation.error.password.size
- The kind must not be null.
- The name must not be null.
AI-assisted analysis of halo-dev/halo@d2f5165f9c (2026-08-14).
Data as JSON: /api/errors/ca308490388ac219.
Report an issue: GitHub.