RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-room-name
error-invalid-room-name
Error message
${escapeHTML(slugifiedName)} is not a valid room name. What it means
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.
Source
Thrown at apps/meteor/server/lib/utils/lib/getValidRoomName.ts:42
function: 'RocketChat.getValidRoomName',
channel_name: cleanName,
});
}
}
}
slugifiedName = cleanName;
}
let nameValidation;
try {
nameValidation = new RegExp(`^${settings.get('UTF8_Channel_Names_Validation')}$`);
} catch (error) {
nameValidation = new RegExp('^[0-9a-zA-Z-_.]+$');
}
if (!nameValidation.test(slugifiedName) || !validateName(slugifiedName)) {
throw new Meteor.Error('error-invalid-room-name', `${escapeHTML(slugifiedName)} is not a valid room name.`, {
function: 'RocketChat.getValidRoomName',
channel_name: escapeHTML(slugifiedName),
});
}
if (options.allowDuplicates !== true) {
const room = await Rooms.findOneByName(slugifiedName);
if (room && room._id !== rid) {
if (settings.get('UI_Allow_room_names_with_special_chars')) {
let tmpName = slugifiedName;
let next = 0;
while (await Rooms.findOneByNameAndNotId(tmpName, rid)) {
tmpName = `${slugifiedName}-${++next}`;
}
slugifiedName = tmpName;
} else if (room.archived) {
throw new Meteor.Error('error-archived-duplicate-name', `There's an archived channel with name ${escapeHTML(slugifiedName)}`, {
function: 'RocketChat.getValidRoomName',View on GitHub (pinned to b2c16d5842)
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
Example fix
// before
await getValidRoomName('café & bar'); // fails the charset regex
// after
await getValidRoomName('cafe-bar'); Defensive patterns
Strategy: validation
Validate before calling
const pattern = (() => {
try {
return new RegExp(`^${settings.get('UTF8_Channel_Names_Validation')}$`);
} catch {
return /^[0-9a-zA-Z-_.]+$/;
}
})();
const blocked = String(settings.get('Accounts_SystemBlockedUsernameList') ?? '').split(',');
const isValidRoomName = (name: string): boolean => pattern.test(name) && !blocked.includes(name.toLowerCase());
if (!isValidRoomName(name)) {
// block submit and suggest a sanitized slug
} Type guard
const isValidRoomName = (name: string): boolean => /^[0-9a-zA-Z-_.]+$/.test(name) && !['all', 'here'].includes(name.toLowerCase());
Try / catch
try {
await getValidRoomName(name, rid);
} catch (error) {
if (error instanceof Meteor.Error && error.error === 'error-invalid-room-name') {
// show the allowed-charset hint and a sanitized suggestion
} else {
throw error;
}
} Prevention
- 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
When it happens
Trigger: Creating/renaming a room whose (slugified) name contains spaces or characters outside the configured charset, or using a name that appears in Accounts_SystemBlockedUsernameList.
Common situations: Workspaces with strict UTF8_Channel_Names_Validation regexes; reserved terms like 'all' blocked workspace-wide; limax slugification producing characters a custom regex forbids.
Related errors
- username-invalid
- error-archived-duplicate-name
- error-duplicate-channel-name
- error-invalid-room
- error-invalid-room
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/29f618e049a14924.
Report an issue: GitHub.