{"record":{"id":"29f618e049a14924","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-room-name","errorCode":"error-invalid-room-name","errorMessage":"${escapeHTML(slugifiedName)} is not a valid room name.","messagePattern":"(.+?) is not a valid room name\\.","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/utils/lib/getValidRoomName.ts","lineNumber":42,"sourceCode":"\t\t\t\t\t\tfunction: 'RocketChat.getValidRoomName',\n\t\t\t\t\t\tchannel_name: cleanName,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tslugifiedName = cleanName;\n\t}\n\n\tlet nameValidation;\n\n\ttry {\n\t\tnameValidation = new RegExp(`^${settings.get('UTF8_Channel_Names_Validation')}$`);\n\t} catch (error) {\n\t\tnameValidation = new RegExp('^[0-9a-zA-Z-_.]+$');\n\t}\n\n\tif (!nameValidation.test(slugifiedName) || !validateName(slugifiedName)) {\n\t\tthrow new Meteor.Error('error-invalid-room-name', `${escapeHTML(slugifiedName)} is not a valid room name.`, {\n\t\t\tfunction: 'RocketChat.getValidRoomName',\n\t\t\tchannel_name: escapeHTML(slugifiedName),\n\t\t});\n\t}\n\n\tif (options.allowDuplicates !== true) {\n\t\tconst room = await Rooms.findOneByName(slugifiedName);\n\t\tif (room && room._id !== rid) {\n\t\t\tif (settings.get('UI_Allow_room_names_with_special_chars')) {\n\t\t\t\tlet tmpName = slugifiedName;\n\t\t\t\tlet next = 0;\n\t\t\t\twhile (await Rooms.findOneByNameAndNotId(tmpName, rid)) {\n\t\t\t\t\ttmpName = `${slugifiedName}-${++next}`;\n\t\t\t\t}\n\t\t\t\tslugifiedName = tmpName;\n\t\t\t} else if (room.archived) {\n\t\t\t\tthrow new Meteor.Error('error-archived-duplicate-name', `There's an archived channel with name ${escapeHTML(slugifiedName)}`, {\n\t\t\t\t\tfunction: 'RocketChat.getValidRoomName',","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/utils/lib/getValidRoomName.ts#L24-L60","documentation":"After slugification, the name either fails the regex built from UTF8_Channel_Names_Validation (falling back to ^[0-9a-zA-Z-_.]+$ when that setting is empty or an invalid regex) or is rejected by validateName, which blocks names listed comma-separated in Accounts_SystemBlockedUsernameList. Details carry function: 'RocketChat.getValidRoomName' and the escaped channel_name.","triggerScenarios":"Creating/renaming a room whose (slugified) name contains spaces or characters outside the configured charset, or using a name that appears in Accounts_SystemBlockedUsernameList.","commonSituations":"Workspaces with strict UTF8_Channel_Names_Validation regexes; reserved terms like 'all' blocked workspace-wide; limax slugification producing characters a custom regex forbids.","solutions":["Sanitize the name to the allowed charset (default: letters, digits, -, _ and .) before submitting","If unicode/special names are intended, relax UTF8_Channel_Names_Validation to a matching regex","Check Accounts_SystemBlockedUsernameList and pick a name not on it"],"exampleFix":"// before\nawait getValidRoomName('café & bar'); // fails the charset regex\n\n// after\nawait getValidRoomName('cafe-bar');","handlingStrategy":"validation","validationCode":"const pattern = (() => {\n  try {\n    return new RegExp(`^${settings.get('UTF8_Channel_Names_Validation')}$`);\n  } catch {\n    return /^[0-9a-zA-Z-_.]+$/;\n  }\n})();\nconst blocked = String(settings.get('Accounts_SystemBlockedUsernameList') ?? '').split(',');\nconst isValidRoomName = (name: string): boolean => pattern.test(name) && !blocked.includes(name.toLowerCase());\nif (!isValidRoomName(name)) {\n  // block submit and suggest a sanitized slug\n}","typeGuard":"const isValidRoomName = (name: string): boolean => /^[0-9a-zA-Z-_.]+$/.test(name) && !['all', 'here'].includes(name.toLowerCase());","tryCatchPattern":"try {\n  await getValidRoomName(name, rid);\n} catch (error) {\n  if (error instanceof Meteor.Error && error.error === 'error-invalid-room-name') {\n    // show the allowed-charset hint and a sanitized suggestion\n  } else {\n    throw error;\n  }\n}","preventionTips":["Slugify user input before creating rooms (the same limax the server uses)","Keep the client-side regex in sync with UTF8_Channel_Names_Validation","Avoid reserved/system-blocked names when suggesting default channel names"],"tags":["rooms","validation","regex","channel-name","meteor"],"backgroundTag":"invalid-room-name","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}