halo-dev/halo · error · ServerWebInputException
Email is required
Error message
Email is required
What it means
Thrown as a ServerWebInputException (HTTP 400) by UserEndpoint.createUser when createUserRequest.email() is blank after the name check passes. Email is required for console user creation.
Source
Thrown at application/src/main/java/run/halo/app/core/endpoint/console/UserEndpoint.java:461
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");
return userService
.getUser(name)
.flatMap(user -> roleServiceView on GitHub (pinned to d2f5165f9c)
Solutions
- Provide a non-blank 'email' value in the create-user request body.
- Add client-side required-field validation on the email input.
- If the user legitimately has no email, assign a deterministic placeholder that satisfies the field.
Example fix
// before: { "name": "alice", "password": "secret" }
// after: { "name": "alice", "email": "alice@example.com", "password": "secret" } Defensive patterns
Strategy: validation
Validate before calling
// require a non-blank email before creating a user
if (StringUtils.isBlank(payload.email)) {
showUserError("Email is required");
return;
} Prevention
- Make the email field required and format-validated in the UI.
- Reject blank emails client-side before constructing the request.
When it happens
Trigger: POST /apis/api.console.halo.run/v1alpha1/users (createUser) with a JSON body where 'name' is present but 'email' is missing, null, empty, or whitespace.
Common situations: Admin leaves email blank; API client omits the email field; organization allows username-only accounts but the API still requires email; migration data missing email column.
Related errors
- validation.error.email.pattern
- Name is required
- 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/ac3297aaaed0a50a.
Report an issue: GitHub.