{"record":{"id":"ac3297aaaed0a50a","repo":"halo-dev/halo","slug":"email-is-required","errorCode":null,"errorMessage":"Email is required","messagePattern":"Email is required","errorType":"validation","errorClass":"ServerWebInputException","httpStatus":400,"severity":"error","filePath":"application/src/main/java/run/halo/app/core/endpoint/console/UserEndpoint.java","lineNumber":461,"sourceCode":"    private Flux<DataBuffer> maxSizeCheck(Flux<DataBuffer> content) {\n        var lenRef = new AtomicInteger(0);\n        return content.doOnNext(dataBuffer -> {\n            int len = lenRef.accumulateAndGet(dataBuffer.readableByteCount(), Integer::sum);\n            if (len > MAX_AVATAR_FILE_SIZE.toBytes()) {\n                throw new ServerWebInputException(\n                        \"The avatar file needs to be smaller than \" + MAX_AVATAR_FILE_SIZE.toMegabytes() + \" MB.\");\n            }\n        });\n    }\n\n    private Mono<ServerResponse> createUser(ServerRequest request) {\n        return request.bodyToMono(CreateUserRequest.class)\n                .doOnNext(createUserRequest -> {\n                    if (StringUtils.isBlank(createUserRequest.name())) {\n                        throw new ServerWebInputException(\"Name is required\");\n                    }\n                    if (StringUtils.isBlank(createUserRequest.email())) {\n                        throw new ServerWebInputException(\"Email is required\");\n                    }\n                })\n                .flatMap(userRequest -> {\n                    User newUser = CreateUserRequest.from(userRequest);\n                    var encryptedPwd = userService.encryptPassword(userRequest.password());\n                    newUser.getSpec().setPassword(encryptedPwd);\n                    return userService.createUser(newUser, userRequest.roles());\n                })\n                .flatMap(user -> ServerResponse.ok()\n                        .contentType(MediaType.APPLICATION_JSON)\n                        .bodyValue(user));\n    }\n\n    private Mono<ServerResponse> getUserByName(ServerRequest request) {\n        final var name = request.pathVariable(\"name\");\n        return userService\n                .getUser(name)\n                .flatMap(user -> roleService","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/halo-dev/halo/blob/d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8/application/src/main/java/run/halo/app/core/endpoint/console/UserEndpoint.java#L443-L479","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before:  { \"name\": \"alice\", \"password\": \"secret\" }\n// after:   { \"name\": \"alice\", \"email\": \"alice@example.com\", \"password\": \"secret\" }","handlingStrategy":"validation","validationCode":"// require a non-blank email before creating a user\nif (StringUtils.isBlank(payload.email)) {\n    showUserError(\"Email is required\");\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make the email field required and format-validated in the UI.","Reject blank emails client-side before constructing the request."],"tags":["user","validation","required-field","email","webflux"],"backgroundTag":null,"analyzedSha":"d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8","analyzedAt":"2026-08-14T00:18:38.915Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}