{"record":{"id":"da4ba49ffdb7cfe5","repo":"RocketChat/Rocket.Chat","slug":"type-and-room-not-compatible","errorCode":null,"errorMessage":"type-and-room-not-compatible","messagePattern":"type-and-room-not-compatible","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/services/video-conference/service.ts","lineNumber":92,"sourceCode":"\t\tuseAppUser = true,\n\t): Promise<VideoConferenceInstructions> {\n\t\treturn wrapExceptions(async () => {\n\t\t\tconst room = await Rooms.findOneById<Pick<IRoom, '_id' | 't' | 'uids' | 'name' | 'fname'>>(rid, {\n\t\t\t\tprojection: { t: 1, uids: 1, name: 1, fname: 1 },\n\t\t\t});\n\n\t\t\tif (!room) {\n\t\t\t\tthrow new Error('invalid-room');\n\t\t\t}\n\n\t\t\tconst user = await Users.findOneById<IUser>(createdBy);\n\t\t\tif (!user) {\n\t\t\t\tthrow new Error('failed-to-load-own-data');\n\t\t\t}\n\n\t\t\tif (type === 'direct') {\n\t\t\t\tif (!isRoomCompatibleWithVideoConfRinging(room.t, room.uids)) {\n\t\t\t\t\tthrow new Error('type-and-room-not-compatible');\n\t\t\t\t}\n\n\t\t\t\treturn this.startDirect(providerName, user, room, data);\n\t\t\t}\n\n\t\t\tif (type === 'livechat') {\n\t\t\t\treturn this.startLivechat(providerName, user, rid);\n\t\t\t}\n\n\t\t\tconst title = (data as Partial<IGroupVideoConference>).title || room.fname || room.name || '';\n\t\t\treturn this.startGroup(providerName, user, room._id, title, data, useAppUser);\n\t\t}).catch((err) => {\n\t\t\tlogger.error({\n\t\t\t\tname: 'Error on VideoConf.create',\n\t\t\t\terr,\n\t\t\t});\n\t\t\tthrow err;\n\t\t});","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/services/video-conference/service.ts#L74-L110","documentation":"Thrown by VideoConferenceService.create when type === 'direct' but the room cannot support direct ringing — isRoomCompatibleWithVideoConfRinging(room.t, room.uids) fails. Direct (ringing) calls require a direct-message room with at most the two call participants; passing type 'direct' with a channel, private group, team, or livechat room id hits this guard.","triggerScenarios":"POST video-conference/create with { type: 'direct', rid: <channel id> }; a front-end hardcodes type 'direct' for every room; a DM grew beyond two uids after multi-user direct changes.","commonSituations":"One call-start code path reused for all room types with a fixed type string; UI state desync between the open room and the type flag; group-DM edge cases.","solutions":["Send the type that matches the room: 'direct' only for 1:1 DM rooms; omit/group type for channels and teams","Derive the type from the room record instead of hardcoding it (see exampleFix)","Hide the ringing call button outside 1:1 DMs","Validate the (type, rid) pair at the API boundary with a schema"],"exampleFix":"// before\nawait VideoConfService.create({ type: 'direct', rid, createdBy, providerName }); // rid is a channel\n\n// after\nconst room = await Rooms.findOneById(rid, { projection: { t: 1, uids: 1 } });\nconst type = room?.t === 'd' && (room.uids?.length ?? 0) <= 2 ? 'direct' : undefined;\nawait VideoConfService.create({ type, rid, createdBy, providerName });","handlingStrategy":"type-guard","validationCode":"const room = await Rooms.findOneById(rid, { projection: { t: 1, uids: 1 } });\nif (type === 'direct' && !(room?.t === 'd' && (room.uids?.length ?? 0) <= 2)) {\n  throw new Meteor.Error('type-and-room-not-compatible');\n}","typeGuard":"function isRoomCompatibleWithDirectRinging(room: Pick<IRoom, 't' | 'uids'>): boolean {\n  return room.t === 'd' && (room.uids?.length ?? 0) <= 2;\n}","tryCatchPattern":"try {\n  await VideoConfService.create({ type: 'direct', rid, createdBy, providerName });\n} catch (err) {\n  if (err instanceof Error && err.message === 'type-and-room-not-compatible') {\n    // fall back to a non-ringing group call for this room\n  }\n  throw err;\n}","preventionTips":["Compute the call type from the room record; never hardcode it","Show ringing UI only in 1:1 DMs","Tie type to room shape in endpoint payload validation"],"tags":["video-conference","direct-messages","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"e4b8178b205510181a96ceefee043d0abcd13e5a","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}