{"record":{"id":"ca308490388ac219","repo":"halo-dev/halo","slug":"name-is-required","errorCode":null,"errorMessage":"Name is required","messagePattern":"Name is required","errorType":"validation","errorClass":"ServerWebInputException","httpStatus":400,"severity":"error","filePath":"application/src/main/java/run/halo/app/core/endpoint/console/UserEndpoint.java","lineNumber":458,"sourceCode":"        });\n    }\n\n    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\");","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/halo-dev/halo/blob/d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8/application/src/main/java/run/halo/app/core/endpoint/console/UserEndpoint.java#L440-L476","documentation":"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.","triggerScenarios":"POST /apis/api.console.halo.run/v1alpha1/users (createUser) with a JSON body where 'name' is missing, null, empty string, or only whitespace.","commonSituations":"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.","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."],"exampleFix":"// before:  { \"email\": \"a@b.com\", \"password\": \"secret\" }\n// after:   { \"name\": \"alice\", \"email\": \"a@b.com\", \"password\": \"secret\" }","handlingStrategy":"validation","validationCode":"// require a non-blank name before creating a user\nif (StringUtils.isBlank(payload.name)) {\n    showUserError(\"Username is required\");\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make the username field required in the admin UI.","Use a lowercase DNS-subdomain-safe name pattern."],"tags":["user","validation","required-field","webflux"],"backgroundTag":null,"analyzedSha":"d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8","analyzedAt":"2026-08-14T00:18:38.915Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}