{"record":{"id":"3906c9a2f933197c","repo":"RocketChat/Rocket.Chat","slug":"error-could-not-change-name","errorCode":"error-could-not-change-name","errorMessage":"Could not change name","messagePattern":"Could not change name","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/users/setRealName.ts","lineNumber":31,"sourceCode":"\t\tsetRealName(name: string): string;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync setRealName(name) {\n\t\tmethodDeprecationLogger.method('setRealName', '9.0.0', '/v1/users.updateOwnBasicInfo');\n\t\tcheck(name, String);\n\t\tconst userId = Meteor.userId();\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'setRealName' });\n\t\t}\n\n\t\tif (!settings.get('Accounts_AllowRealNameChange')) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'setRealName' });\n\t\t}\n\n\t\tif (!(await setRealName(userId, name))) {\n\t\t\tthrow new Meteor.Error('error-could-not-change-name', 'Could not change name', {\n\t\t\t\tmethod: 'setRealName',\n\t\t\t});\n\t\t}\n\n\t\treturn name;\n\t},\n});\n\nRateLimiter.limitMethod('setRealName', 1, 1000, {\n\tuserId: () => true,\n});\n","sourceCodeStart":13,"sourceCodeEnd":43,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/users/setRealName.ts#L13-L43","documentation":"Thrown when the setRealName library function (server/lib/users/setRealName.ts) returns falsy. It returns undefined when the target user record is missing OR when Accounts_RequireNameForSignUp is true and the trimmed new name is empty - i.e. attempting to clear a name on a workspace that requires names.","triggerScenarios":"setRealName called with '' or whitespace-only name while Accounts_RequireNameForSignUp=true; or the userId's document no longer exists in the users collection.","commonSituations":"Profile forms with an optional name field that submit empty strings instead of omitting the field; name-required workspaces; races where the account is deleted mid-submit.","solutions":["Send a non-empty trimmed name, or skip the call entirely, when the name field is blank on a name-required workspace","Verify Accounts_RequireNameForSignUp state before allowing 'clear name' UX","If clearing names is a legitimate feature, ask the admin to disable Accounts_RequireNameForSignUp"],"exampleFix":"// before\nMeteor.call('setRealName', nameField.value); // may be ''\n\n// after\nconst name = nameField.value.trim();\nif (name) Meteor.call('setRealName', name);","handlingStrategy":"validation","validationCode":"const trimmed = typeof name === 'string' ? name.trim() : '';\nif (requireNameForSignUp && !trimmed) {\n  showFieldError('name', 'Name is required on this server');\n  return; // do not call setRealName\n}\nif (trimmed) Meteor.call('setRealName', trimmed);","typeGuard":"const isNonEmptyTrimmedString = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'error-could-not-change-name') {\n    showFieldError('name', 'Could not save name - check it is not empty');\n  }\n}","preventionTips":["Omit the setRealName call when the trimmed name is empty instead of sending ''","Respect Accounts_RequireNameForSignUp in form validation","Treat this error as a signal the target user vanished or the name requirement blocked the save"],"tags":["meteor","users","validation","settings"],"backgroundTag":"required-field-missing","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}