{"record":{"id":"c07fcf95dcbc046b","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-name-c07fcf","errorCode":"error-invalid-name","errorMessage":"Invalid name","messagePattern":"Invalid name","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/rooms/createRoom.ts","lineNumber":205,"sourceCode":"\t\t\tmethod: 'createRoom',\n\t\t});\n\t}\n\n\tif (type === 'd') {\n\t\treturn createDirectRoom(members as IUser[], extraData, { ...options, creator: options?.creator || owner?._id });\n\t}\n\n\tconst memberList = [...members];\n\n\tif (!onlyUsernames(memberList)) {\n\t\tthrow new Meteor.Error(\n\t\t\t'error-invalid-members',\n\t\t\t'members should be an array of usernames if provided for rooms other than direct messages',\n\t\t);\n\t}\n\n\tif (!isValidName(name)) {\n\t\tthrow new Meteor.Error('error-invalid-name', 'Invalid name', {\n\t\t\tfunction: 'RocketChat.createRoom',\n\t\t});\n\t}\n\n\tif (!owner) {\n\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\tfunction: 'RocketChat.createRoom',\n\t\t});\n\t}\n\n\tif (!owner?.username) {\n\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\tfunction: 'RocketChat.createRoom',\n\t\t});\n\t}\n\n\tif (!excludeSelf && owner.username && !memberList.includes(owner.username)) {\n\t\tmemberList.push(owner.username);","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/rooms/createRoom.ts#L187-L223","documentation":"createRoom validates the room name with isValidName (must be a non-empty string after trim). A non-string, empty, or whitespace-only name triggers error-invalid-name with function RocketChat.createRoom in the error details.","triggerScenarios":"Calling createRoom with name = '', '   ', undefined, null, or a non-string value (number, object). Only applies to non-DM rooms since type 'd' returns early to createDirectRoom.","commonSituations":"Dynamic room creation where the name comes from user input or a template that rendered empty; passing the room name positionally and accidentally swapping arguments; team/discussion creation flows where the parent name was never resolved.","solutions":["Default or validate the name before calling createRoom: name?.trim() && name or throw a user-facing error early","Check argument order in the call signature (type, name, owner, members, extraData)","Sanitize upstream input (REST endpoint / method param) with the same trim + non-empty rule"],"exampleFix":"// before\ncreateRoom('c', userInput.name, owner, members, extraData);\n\n// after\nconst name = userInput.name?.trim();\nif (!name) throw new Meteor.Error('error-invalid-name', 'Invalid name');\ncreateRoom('c', name, owner, members, extraData);","handlingStrategy":"validation","validationCode":"const name = typeof rawName === 'string' ? rawName.trim() : '';\nif (!name) {\n  throw new Meteor.Error('error-invalid-name', 'Room name is required');\n}\nawait createRoom(type, name, owner, members, extraData);","typeGuard":"const isValidName = (name: unknown): name is string =>\n  typeof name === 'string' && name.trim().length > 0;","tryCatchPattern":"try {\n  await createRoom(type, name, owner, members, extraData);\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'error-invalid-name') {\n    // prompt the user for a valid name\n  }\n  throw err;\n}","preventionTips":["Trim and require non-empty names in the UI before submission","Reuse the same isValidName predicate on the client for instant feedback","Never build room names from unvalidated template variables"],"tags":["room-creation","validation","name"],"backgroundTag":"schema-validation-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}