{"record":{"id":"5a19db8d1499e9a2","repo":"halo-dev/halo","slug":"validation-error-password-size-5a19db","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/uc/UcUserEndpoint.java","lineNumber":162,"sourceCode":"    /**\n     * Payload for setting or changing the current user's password.\n     *\n     * @param oldPassword old password, required and verified only when the current user has a password; ignored\n     *     otherwise\n     * @param password new password of the current user\n     */\n    record ChangeMyPasswordRequest(\n            @Schema(\n                    description = \"Old password. Required and verified only when the current user \"\n                            + \"has a password; ignored otherwise.\")\n            String oldPassword,\n\n            @Schema(requiredMode = REQUIRED, minLength = 5, maxLength = 257)\n            String password) {\n\n        public ChangeMyPasswordRequest {\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","sourceCodeStart":144,"sourceCodeEnd":168,"githubUrl":"https://github.com/halo-dev/halo/blob/d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8/application/src/main/java/run/halo/app/core/endpoint/uc/UcUserEndpoint.java#L144-L168","documentation":"Thrown as an UnsatisfiedAttributeValueException (HTTP 400) with code 'validation.error.password.size' from the ChangeMyPasswordRequest compact constructor in the user-center endpoint. It fires when password is null, shorter than 5 chars, or longer than 257 chars — the same bounds as the console change-own-password, with i18n args [5,257].","triggerScenarios":"POST to the user-center change-my-password endpoint with a 'password' that is null, length < 5, or length > 257. The compact constructor validates eagerly before Spring binding validation.","commonSituations":"User submits empty new password; very long generated password exceeds 257 chars; client omitted the password field; weak '1234'-style test password; frontend lacks length guidance.","solutions":["Submit a new password with length between 5 and 257 inclusive.","Mirror the 5–257 bounds in the client UI and block submit outside that range.","Localize the failure via code 'validation.error.password.size' with args [5,257]."],"exampleFix":"// before:  { \"password\": \"1234\" }\n// after:   { \"oldPassword\": \"x\", \"password\": \"strong-pass-42\" }","handlingStrategy":"validation","validationCode":"// enforce 5..257 length before the change-password 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":["Mirror the 5–257 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","user-center"],"backgroundTag":null,"analyzedSha":"d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8","analyzedAt":"2026-08-14T00:18:38.915Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}