{"record":{"id":"08f8769ea6b8930a","repo":"RocketChat/Rocket.Chat","slug":"error-archived-duplicate-name","errorCode":"error-archived-duplicate-name","errorMessage":"There's an archived channel with name ${cleanName}","messagePattern":"There's an archived channel with name (.+?)","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/utils/lib/getValidRoomName.ts","lineNumber":18,"sourceCode":"import { Rooms } from '@rocket.chat/models';\nimport { escapeHTML } from '@rocket.chat/tools';\nimport limax from 'limax';\nimport { Meteor } from 'meteor/meteor';\n\nimport { settings } from '../../../settings';\nimport { validateName } from '../../shared/validateName';\n\nexport const getValidRoomName = async (displayName: string, rid = '', options: { allowDuplicates?: boolean } = {}) => {\n\tlet slugifiedName = displayName;\n\n\tif (settings.get('UI_Allow_room_names_with_special_chars')) {\n\t\tconst cleanName = limax(displayName, { maintainCase: true });\n\t\tif (options.allowDuplicates !== true) {\n\t\t\tconst room = await Rooms.findOneByDisplayName(displayName);\n\t\t\tif (room && room._id !== rid) {\n\t\t\t\tif (room.archived) {\n\t\t\t\t\tthrow new Meteor.Error('error-archived-duplicate-name', `There's an archived channel with name ${cleanName}`, {\n\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} else {\n\t\t\t\t\tthrow new Meteor.Error('error-duplicate-channel-name', `A channel with name '${cleanName}' exists`, {\n\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')}$`);","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/utils/lib/getValidRoomName.ts#L1-L36","documentation":"In the UI_Allow_room_names_with_special_chars path, getValidRoomName slugifies the display name (limax, maintainCase) and looks up Rooms.findOneByDisplayName(displayName); a different room (room._id !== rid) with the same display name exists and its archived flag is set. Archived duplicates get a dedicated code so callers can offer 'unarchive' instead of 'rename'. Details carry function: 'RocketChat.getValidRoomName' and channel_name.","triggerScenarios":"Creating or renaming a channel to the display name of an archived channel while options.allowDuplicates is not true.","commonSituations":"Teams recreating archived channels instead of unarchiving them; retention policies that keep archived channels around forever; imports that archive name-colliding rooms.","solutions":["Unarchive the existing channel and reuse it","Delete the archived channel if it is truly dead, then retry the create","If the flow genuinely permits duplicate display names, pass { allowDuplicates: true } to getValidRoomName"],"exampleFix":"// before\nawait getValidRoomName('quarterly-reports'); // archived duplicate exists\n\n// after\nawait getValidRoomName('quarterly-reports', '', { allowDuplicates: true });","handlingStrategy":"validation","validationCode":"import { Rooms } from '@rocket.chat/models';\n\nconst existing = await Rooms.findOneByDisplayName(displayName);\nif (existing && existing._id !== rid && existing.archived) {\n  // offer 'unarchive <name>' instead of creating\n}","typeGuard":null,"tryCatchPattern":"try {\n  await getValidRoomName(name, rid);\n} catch (error) {\n  if (error instanceof Meteor.Error && error.error === 'error-archived-duplicate-name') {\n    // suggest unarchiving the channel named in error.details.channel_name\n  } else {\n    throw error;\n  }\n}","preventionTips":["Check for archived namesakes before presenting create as available","Prefer unarchive over recreate for retention continuity","Read channel_name from error details to drive the unarchive prompt"],"tags":["rooms","duplicate","archived","channel-name","meteor"],"backgroundTag":"duplicate-room-name","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}