{"record":{"id":"a4563ccbe914656d","repo":"halo-dev/halo","slug":"validation-error-password-size","errorCode":"validation.error.password.size","errorMessage":"password is required.","messagePattern":"password is required\\.","errorType":"validation","errorClass":"UnsatisfiedAttributeValueException","httpStatus":400,"severity":"error","filePath":"application/src/main/java/run/halo/app/core/endpoint/console/UserEndpoint.java","lineNumber":663,"sourceCode":"                .flatMap(updatedUser -> ServerResponse.ok()\n                        .contentType(MediaType.APPLICATION_JSON)\n                        .bodyValue(updatedUser));\n    }\n\n    /**\n     * Payload for changing the current user's password.\n     *\n     * @param oldPassword old password\n     * @param password new password\n     */\n    record ChangeOwnPasswordRequest(\n            @Schema(requiredMode = REQUIRED) String oldPassword,\n\n            @Schema(requiredMode = REQUIRED, minLength = 5) String password) {\n\n        public ChangeOwnPasswordRequest {\n            if (password == null || password.length() < 5 || password.length() > 257) {\n                throw new UnsatisfiedAttributeValueException(\n                        \"password is required.\", \"validation.error.password.size\", new Object[] {5, 257});\n            }\n        }\n    }\n\n    /**\n     * Payload for changing a user's password.\n     *\n     * @param password new password\n     */\n    record ChangePasswordRequest(\n            @Schema(requiredMode = REQUIRED, minLength = 5) String password) {}\n\n    Mono<ServerResponse> me(ServerRequest request) {\n        return ReactiveSecurityContextHolder.getContext()\n                .map(SecurityContext::getAuthentication)\n                .filter(Authentication::isAuthenticated)\n                .flatMap(auth -> userService.getUser(auth.getName()).flatMap(user -> {","sourceCodeStart":645,"sourceCodeEnd":681,"githubUrl":"https://github.com/halo-dev/halo/blob/d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8/application/src/main/java/run/halo/app/core/endpoint/console/UserEndpoint.java#L645-L681","documentation":"Thrown as an UnsatisfiedAttributeValueException (HTTP 400) with code 'validation.error.password.size' from the ChangeOwnPasswordRequest compact constructor. It fires when password is null, shorter than 5 chars, or longer than 257 chars. The code is an i18n key with args [5,257] for localized messaging.","triggerScenarios":"POST to change the current user's own password (console endpoint) with a 'password' that is null, has length < 5, or length > 257. The compact constructor validates before Spring's binding validation runs.","commonSituations":"User submits an empty new password; password generator produced a >257 char token; frontend sent only oldPassword; paste error truncated the password to a few chars; test fixture used '123' as a weak password.","solutions":["Submit a new password whose length is between 5 and 257 inclusive.","Enforce the same 5–257 bounds in the client UI before enabling submit.","Localize the response using code 'validation.error.password.size' with args [5,257]."],"exampleFix":"// before:  { \"oldPassword\": \"x\", \"password\": \"123\" }\n// after:   { \"oldPassword\": \"x\", \"password\": \"strong-pass-42\" }","handlingStrategy":"validation","validationCode":"// enforce 5..257 length before the request\nString p = newPassword;\nif (p == null || p.length() < 5 || p.length() > 257) {\n    showUserError(\"Password must be 5–257 characters\");\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Show 5–257 length bounds in the UI and block submit outside them.","Localize failure via code 'validation.error.password.size' (args [5,257])."],"tags":["user","password","validation","i18n","webflux"],"backgroundTag":null,"analyzedSha":"d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8","analyzedAt":"2026-08-14T00:18:38.915Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}