{"record":{"id":"d5d630164b1e779f","repo":"RocketChat/Rocket.Chat","slug":"only-channels-private-groups-and-direct-messages","errorCode":null,"errorMessage":"Only channels, private groups and direct messages can be created.","messagePattern":"Only channels, private groups and direct messages can be created\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/rooms.ts","lineNumber":75,"sourceCode":"export class AppRoomBridge extends RoomBridge {\n\tconstructor(private readonly orch: IAppServerOrchestrator) {\n\t\tsuper();\n\t}\n\n\tprotected async create(room: IRoom, members: Array<string>, appId: string): Promise<string> {\n\t\tthis.orch.debugLog(`The App ${appId} is creating a new room.`, room);\n\n\t\tconst rcRoom = await this.orch.getConverters()?.get('rooms').convertAppRoom(room);\n\n\t\tswitch (room.type) {\n\t\t\tcase RoomType.CHANNEL:\n\t\t\t\treturn this.createChannel(room.creator.id, rcRoom, members);\n\t\t\tcase RoomType.PRIVATE_GROUP:\n\t\t\t\treturn this.createPrivateGroup(room.creator.id, rcRoom, members);\n\t\t\tcase RoomType.DIRECT_MESSAGE:\n\t\t\t\treturn this.createDirectMessage(room.creator.id, members);\n\t\t\tdefault:\n\t\t\t\tthrow new Error('Only channels, private groups and direct messages can be created.');\n\t\t}\n\t}\n\n\tprivate prepareExtraData(room: Record<string, any>): Record<string, unknown> {\n\t\tconst extraData = Object.assign({}, room);\n\t\tdelete extraData.name;\n\t\tdelete extraData.t;\n\t\tdelete extraData.ro;\n\t\tdelete extraData.customFields;\n\n\t\treturn extraData;\n\t}\n\n\tprivate async createChannel(userId: string, room: ICoreRoom, members: string[]): Promise<string> {\n\t\treturn (await createChannelMethod(userId, room.name || '', members, room.ro, room.customFields, this.prepareExtraData(room))).rid;\n\t}\n\n\tprivate async createDirectMessage(userId: string, members: string[]): Promise<string> {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/app/apps/server/bridges/rooms.ts#L57-L93","documentation":"AppRoomBridge.create only handles three apps-engine room types — RoomType.CHANNEL ('c'), RoomType.PRIVATE_GROUP ('p') and RoomType.DIRECT_MESSAGE ('d'); every other room.type hits the default branch and throws. Notably Team ('t') and Livechat ('l') rooms cannot be created through this bridge.","triggerScenarios":"Creating a room with room.type = RoomType.TEAMS or RoomType.LIVECHAT (or any custom/raw string); copying the type of a fetched livechat or team room into a new IRoom passed to the create API.","commonSituations":"Apps trying to provision teams or omnichannel rooms via the apps API; building IRoom objects by hand with a wrong type value; assuming every value of the apps-engine RoomType enum is creatable.","solutions":["Restrict creation to CHANNEL, PRIVATE_GROUP and DIRECT_MESSAGE","Create teams/omnichannel rooms through their dedicated server/REST APIs instead of the room bridge","Set room.type explicitly from the RoomType enum — never from unvalidated strings","Validate room.type before calling create and fail with your own descriptive error"],"exampleFix":"// before\nconst room = { type: 't' as any, ... }; // team room -> default branch throws\nawait app.getRocketChat().getChat().createRoom(room, members);\n// after\nconst room = { type: RoomType.CHANNEL, creator, name: 'my-channel' };\nawait app.getRocketChat().getChat().createRoom(room, members);","handlingStrategy":"type-guard","validationCode":"const CREATABLE = new Set([RoomType.CHANNEL, RoomType.PRIVATE_GROUP, RoomType.DIRECT_MESSAGE]);\nif (!CREATABLE.has(room.type)) {\n  throw new Error(`room type '${room.type}' cannot be created via the apps API`);\n}\nawait app.getRocketChat().getChat().createRoom(room, members);","typeGuard":"import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';\nconst isCreatableRoomType = (t: unknown): t is RoomType.CHANNEL | RoomType.PRIVATE_GROUP | RoomType.DIRECT_MESSAGE =>\n  t === RoomType.CHANNEL || t === RoomType.PRIVATE_GROUP || t === RoomType.DIRECT_MESSAGE;\n\nif (!isCreatableRoomType(room.type)) return;","tryCatchPattern":"try {\n  await app.getRocketChat().getChat().createRoom(room, members);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('Only channels, private groups and direct messages')) {\n    app.getLogger().error(`room type ${room.type} is not creatable via apps`);\n    return;\n  }\n  throw err;\n}","preventionTips":["Set room.type only from the RoomType enum — never from strings or copied fetched rooms","Create teams/omnichannel rooms via their dedicated APIs, not this bridge","Whitelist creatable types at the edge of your app code","Test creation for each type you support"],"tags":["apps-engine","rooms","room-type","validation","unsupported-operation"],"backgroundTag":"unsupported-room-type","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}