{"record":{"id":"14d1eaa7897fa583","repo":"RocketChat/Rocket.Chat","slug":"invalid-call-target","errorCode":null,"errorMessage":"invalid-call-target","messagePattern":"invalid-call-target","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/services/video-conference/service.ts","lineNumber":739,"sourceCode":"\t\tconst subscriptions = Subscriptions.findByRoomIdAndNotUserId(call.rid, call.createdBy._id, {\n\t\t\tprojection: { 'u._id': 1, '_id': 0 },\n\t\t});\n\n\t\tfor await (const subscription of subscriptions) {\n\t\t\tawait this.sendPushNotification(call, subscription.u._id);\n\t\t}\n\t}\n\n\tprivate async startDirect(\n\t\tproviderName: string,\n\t\tuser: IUser,\n\t\t{ _id: rid, uids }: AtLeast<IRoom, '_id' | 'uids'>,\n\t\textraData?: Partial<IDirectVideoConference>,\n\t): Promise<DirectCallInstructions> {\n\t\tconst calleeId = uids?.filter((uid) => uid !== user._id).pop();\n\t\tif (!calleeId) {\n\t\t\t// Are you trying to call yourself?\n\t\t\tthrow new Error('invalid-call-target');\n\t\t}\n\n\t\tconst callId = await VideoConferenceModel.createDirect({\n\t\t\t...extraData,\n\t\t\trid,\n\t\t\tcreatedBy: {\n\t\t\t\t_id: user._id,\n\t\t\t\tname: user.name as string,\n\t\t\t\tusername: user.username as string,\n\t\t\t},\n\t\t\tproviderName,\n\t\t});\n\n\t\tawait this.runNewVideoConferenceEvent(callId);\n\n\t\tawait this.maybeCreateDiscussion(callId, user);\n\n\t\tconst call = (await this.getUnfiltered(callId)) as IDirectVideoConference | null;","sourceCodeStart":721,"sourceCodeEnd":757,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/services/video-conference/service.ts#L721-L757","documentation":"Thrown by startDirect() when computing the callee: uids.filter(uid => uid !== user._id).pop() is empty, i.e. the direct-message room contains no member other than the caller. The source comment spells out the main case: 'Are you trying to call yourself?'. A DM with only yourself (self/notes room) or a room document with missing/empty uids cannot be a direct call target.","triggerScenarios":"Starting a video call in a self-chat / 'save messages' room (uids === [callerId]); starting a call on a room whose uids array is undefined or lacks a second user (corrupted or hand-crafted room doc); calling startCall with an rid that resolves to such a room.","commonSituations":"Users clicking the call button in their own notes/self conversation; imported or migrated rooms with incomplete uids; automation or test code reusing the rid of a self-room.","solutions":["Start the call from a DM with exactly one other member instead of a self-chat","If building an integration or custom client, verify the room type and that uids contains another user before invoking start","Repair room documents whose uids array is missing or malformed (audit the rooms collection)","Hide the call button for self-chats in custom clients (stock clients already do)"],"exampleFix":"// before\nawait videoConfService.startCall(user, { _id: rid, uids }); // may throw 'invalid-call-target'\n\n// after\nconst calleeId = uids?.filter((uid) => uid !== user._id).pop();\nif (!calleeId) {\n\treturn refuse('Cannot start a direct call in a room with no other member');\n}\nawait videoConfService.startCall(user, { _id: rid, uids });","handlingStrategy":"validation","validationCode":"const calleeId = room.uids?.filter((uid) => uid !== user._id).pop();\nif (!calleeId) {\n\treturn notifyUser('Cannot start a call in a room without another member');\n}\nawait videoConfService.startCall(user, { _id: room._id, uids: room.uids });","typeGuard":"const hasCallTarget = (room: { uids?: string[] }, uid: string): boolean =>\n\tBoolean(room.uids?.filter((u) => u !== uid).pop());","tryCatchPattern":"catch (err) { if (err instanceof Error && err.message === 'invalid-call-target') { /* tell the caller this room has no other member */ } else throw err; }","preventionTips":["Hide call buttons in self-chats and notes rooms","Validate room.uids contains a user other than the caller before enabling direct-call UI","Reject start-call API calls for rooms whose uids include only the caller"],"tags":["video-conference","direct-message","room-data","validation"],"backgroundTag":"invalid-recipient","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"}