{"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":"Error","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/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/app/apps/server/bridges/rooms.ts#L57-L93","documentation":"Thrown by AppRoomBridge.create when room.type does not match RoomType.CHANNEL, RoomType.PRIVATE_GROUP, or RoomType.DIRECT_MESSAGE. The Apps Engine room-creation surface supports only those three room kinds; any other type (or an undefined/misspelled type value) falls through the switch to the default branch and is rejected.","triggerScenarios":"An App calls the modify creator's room builder with room.type set to a livechat room type, a thread/discussion type, an omni room type, or left undefined. Also triggered by string typos like 'c' or 'p' instead of the enum constants.","commonSituations":"Apps that try to create omnichannel/livechat rooms via the generic room creator instead of the livechat accessor; passing raw core-typings room type letters ('c','p','d') instead of the RoomType enum; building an IRoom from a webhook payload whose type field was not mapped to the enum.","solutions":["Set room.type using the RoomType enum from @rocket.chat/apps-engine/definition/rooms (RoomType.CHANNEL, RoomType.PRIVATE_GROUP, RoomType.DIRECT_MESSAGE).","For livechat/omnichannel rooms, use the livechat accessor (ILivechatCreator) instead of the generic room creator.","Map any external type code to one of the three supported enum values before calling create."],"exampleFix":"// before\nroom.setType('c'); // raw letter — falls through\nawait modify.getCreator().startRoom(room).done();\n\n// after\nimport { RoomType } from '@rocket.chat/apps-engine/definition/rooms';\nroom.setType(RoomType.CHANNEL);\nawait modify.getCreator().startRoom(room).done();","handlingStrategy":"type-guard","validationCode":"import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';\n\nconst SUPPORTED = new Set<RoomType>([RoomType.CHANNEL, RoomType.PRIVATE_GROUP, RoomType.DIRECT_MESSAGE]);\nif (!SUPPORTED.has(room.type)) {\n  throw new Error(`Unsupported room type: ${room.type}. Use the livechat accessor for omni rooms.`);\n}\nawait modify.getCreator().startRoom(room).done();","typeGuard":"import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';\n\nfunction isSupportedRoomType(type: unknown): type is RoomType {\n  return type === RoomType.CHANNEL || type === RoomType.PRIVATE_GROUP || type === RoomType.DIRECT_MESSAGE;\n}","tryCatchPattern":null,"preventionTips":["Always set room.type from the RoomType enum, never from raw letters or external strings.","For livechat/omnichannel rooms use the livechat accessor, not the generic room creator.","Map external type codes to the enum at the boundary where data enters your App."],"tags":["apps-engine","room-bridge","validation","room-type","enum","switch-default"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}