{"record":{"id":"779381c01266d8cd","repo":"laurent22/joplin","slug":"full-name-must-be-at-most-256-characters","errorCode":null,"errorMessage":"Full name must be at most 256 characters","messagePattern":"Full name must be at most 256 characters","errorType":"validation","errorClass":"ErrorUnprocessableEntity","httpStatus":422,"severity":"error","filePath":"packages/server/src/models/UserModel.ts","lineNumber":481,"sourceCode":"\t\tif (options.isNew) {\n\t\t\tif (!user.email) throw new ErrorUnprocessableEntity('email must be set');\n\t\t\tif ('email' in user && !user.email.includes('@')) throw new ErrorUnprocessableEntity(`Should include @ in email address, email: ${user.email}`);\n\t\t\tif (!user.password && !user.must_set_password) throw new ErrorUnprocessableEntity('password must be set');\n\t\t} else {\n\t\t\tif ('email' in user && !user.email) throw new ErrorUnprocessableEntity('email must be set');\n\t\t\tif (user.email && !user.email.includes('@')) throw new ErrorUnprocessableEntity(`Should include @ in email address, email: ${user.email}`);\n\t\t\tif ('password' in user && !user.password) throw new ErrorUnprocessableEntity('password must be set');\n\t\t}\n\n\t\tif (user.email) {\n\t\t\tconst existingUser = await this.loadByEmail(user.email);\n\t\t\tif (existingUser && existingUser.id !== user.id) throw new ErrorUnprocessableEntity(`there is already a user with this email: ${user.email}`);\n\t\t\t// See https://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690 (found via https://stackoverflow.com/a/574698)\n\t\t\tif (user.email.length > 254) throw new ErrorUnprocessableEntity('Please enter an email address between 0 and 254 characters');\n\t\t\tvalidateEmail(user.email);\n\t\t}\n\n\t\tif (user.full_name && user.full_name.length > 256) throw new ErrorUnprocessableEntity('Full name must be at most 256 characters');\n\n\t\treturn super.validate(user, options);\n\t}\n\n\t// public async delete(id: string): Promise<void> {\n\t// \tconst shares = await this.models().share().sharesByUser(id);\n\n\t// \tawait this.withTransaction(async () => {\n\t// \t\tawait this.models().item().deleteExclusivelyOwnedItems(id);\n\t// \t\tawait this.models().share().delete(shares.map(s => s.id));\n\t// \t\tawait this.models().userItem().deleteByUserId(id);\n\t// \t\tawait this.models().session().deleteByUserId(id);\n\t// \t\tawait this.models().notification().deleteByUserId(id);\n\t// \t\tawait super.delete(id);\n\t// \t}, 'UserModel::delete');\n\t// }\n\n\tprivate async confirmEmail(user: User) {","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/laurent22/joplin/blob/981a03c5c9e88130bccff4db47c411d35ec7ae2c/packages/server/src/models/UserModel.ts#L463-L499","documentation":"UserModel.validate throws ErrorUnprocessableEntity('Full name must be at most 256 characters') when the user's full_name field exceeds 256 characters. This bounds the stored display name to fit the database column and UI layouts.","triggerScenarios":"Saving or updating a user whose full_name string length is greater than 256 characters.","commonSituations":"Importing names from external directories (LDAP/CSV) that concatenate many fields; sync tools copying long 'displayName' attributes; users pasting long text into the name field.","solutions":["Truncate or shorten the full_name value to 256 characters or fewer before saving.","Strip concatenated metadata from imported directory names.","Enforce a maxlength=256 constraint on the name input in the client form."],"exampleFix":"// before\nawait models.user().save({ email: 'a@b.com', password: 'x', full_name: veryLongName });\n// after\nconst fullName = veryLongName.slice(0, 256);\nawait models.user().save({ email: 'a@b.com', password: 'x', full_name: fullName });","handlingStrategy":"validation","validationCode":"if (user.full_name && user.full_name.length > 256) throw new Error('Full name too long');","typeGuard":"function isValidFullName(name?: string): boolean { return !name || name.length <= 256; }","tryCatchPattern":"try { await models.user().save(user, opts); } catch (e) { if (/Full name must be at most 256/.test(e.message)) /* truncate and retry */; }","preventionTips":["Truncate directory-sourced display names to 256 chars at import time.","Set maxlength=256 on name inputs in clients."],"tags":["server","validation","field-length"],"backgroundTag":"value-out-of-range","analyzedSha":"981a03c5c9e88130bccff4db47c411d35ec7ae2c","analyzedAt":"2026-09-17T14:49:40.960Z","contentChangedAt":"2026-09-17T14:49:40.960Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}