{"record":{"id":"e15c6deac2ebd772","repo":"RocketChat/Rocket.Chat","slug":"error-room-does-not-exist-e15c6d","errorCode":"error-room-does-not-exist","errorMessage":"This room does not exist","messagePattern":"This room does not exist","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/chat.ts","lineNumber":302,"sourceCode":"\t\tasync function action() {\n\t\t\tif (!settings.get<boolean>('Threads_enabled')) {\n\t\t\t\tthrow new Meteor.Error('error-not-allowed', 'Threads Disabled');\n\t\t\t}\n\n\t\t\tconst { tmid } = this.bodyParams;\n\n\t\t\tconst thread = await Messages.findOneById(tmid, { projection: { rid: 1 } });\n\t\t\tif (!thread?.rid) {\n\t\t\t\tthrow new Meteor.Error('error-invalid-message', 'Invalid Message');\n\t\t\t}\n\n\t\t\tconst [user, room] = await Promise.all([\n\t\t\t\tUsers.findOneById(this.userId),\n\t\t\t\tRooms.findOneById(thread.rid, { projection: { ...roomAccessAttributes, t: 1, _id: 1 } }),\n\t\t\t]);\n\n\t\t\tif (!room) {\n\t\t\t\tthrow new Meteor.Error('error-room-does-not-exist', 'This room does not exist');\n\t\t\t}\n\n\t\t\tif (!user || !(await canAccessRoomAsync(room, user))) {\n\t\t\t\tthrow new Meteor.Error('error-not-allowed', 'Not Allowed');\n\t\t\t}\n\n\t\t\tawait callbacks.run('beforeReadMessages', room._id, user._id);\n\t\t\tawait readThread({ user, room, tmid });\n\n\t\t\treturn API.v1.success();\n\t\t},\n\t)\n\t.post(\n\t\t'chat.update',\n\t\t{\n\t\t\tauthRequired: true,\n\t\t\tbody: isChatUpdateProps,\n\t\t\tresponse: {","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/api/v1/chat.ts#L284-L320","documentation":"Thrown by POST chat.readThread (apps/meteor/server/api/v1/chat.ts:298) when the thread's parent message exists (tmid resolved to an rid) but Rooms.findOneById(thread.rid) returns null. The thread points at a room record that no longer exists in the database, so there is no room to mark read. This is a data-integrity condition: the message survived while its room was deleted.","triggerScenarios":"POST /api/v1/chat.readThread with a valid tmid whose room was deleted (cascade cleanup missed the message), typically after a room was removed while messages with that rid remained, or in workspaces restored from partial backups where the Messages collection is newer than Rooms.","commonSituations":"Retention/erase jobs that delete rooms but leave orphan thread parents; workspace migrations or backup restores with collection drift; test fixtures seeded with messages but no matching room documents.","solutions":["Treat as a permanent 404: remove the local unread/thread state for that tmid and stop calling readThread for it.","Sanity-check the room with GET /api/v1/rooms.info?roomId=<rid> (from chat.getMessage's response) before marking read.","If you administer the workspace, purge the orphaned message(s) with rid pointing to the deleted room so the data is consistent again.","If you believe the room should still exist, inspect the Rooms collection for the id and restore/recreate the room."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const msg = await rc.get('/api/v1/chat.getMessage', { params: { msgId: tmid } });\nconst room = await rc.get('/api/v1/rooms.info', { params: { roomId: msg.message.rid } });\nif (!room?.room) throw new Error('thread room missing');","typeGuard":null,"tryCatchPattern":"try {\n  await rc.post('/api/v1/chat.readThread', { tmid });\n} catch (e) {\n  if (e?.errorType === 'error-room-does-not-exist') dropOrphanThread(tmid); // permanent, do not retry\n  else throw e;\n}","preventionTips":["Periodically reconcile cached threads against live rooms; orphaned parents indicate retention or cleanup gaps.","If you operate the server, investigate why Messages outlived their Rooms (partial restore, buggy erase job)."],"tags":["rocket-chat","rest-api","threads","room-deleted","data-integrity","chat-readthread"],"backgroundTag":"room-not-found","analyzedSha":"e4b8178b205510181a96ceefee043d0abcd13e5a","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}