{"record":{"id":"0d3657e4510c4310","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-room-0d3657","errorCode":"error-invalid-room","errorMessage":"error-invalid-room","messagePattern":"error-invalid-room","errorType":"exception","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/ee/server/api/v1/omnichannel/transcript.ts","lineNumber":20,"sourceCode":"import { LivechatRooms } from '@rocket.chat/models';\n\nimport { API } from '../../../../../server/api';\nimport { canAccessRoomAsync } from '../../../../../server/lib/authorization/canAccessRoom';\nimport { requestPdfTranscript } from '../../../lib/omnichannel/requestPdfTranscript';\n\nAPI.v1.addRoute(\n\t'omnichannel/:rid/request-transcript',\n\t{ authRequired: true, permissionsRequired: ['request-pdf-transcript'], license: ['livechat-enterprise'] },\n\t{\n\t\tasync post() {\n\t\t\tconst room = await LivechatRooms.findOneById<Pick<IOmnichannelRoom, '_id' | 'open' | 'v' | 't' | 'pdfTranscriptFileId'>>(\n\t\t\t\tthis.urlParams.rid,\n\t\t\t\t{\n\t\t\t\t\tprojection: { _id: 1, open: 1, v: 1, t: 1, pdfTranscriptFileId: 1 },\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (!room) {\n\t\t\t\tthrow new Error('error-invalid-room');\n\t\t\t}\n\n\t\t\tif (!(await canAccessRoomAsync(room, { _id: this.userId }))) {\n\t\t\t\tthrow new Error('error-not-allowed');\n\t\t\t}\n\n\t\t\t// Flow is as follows:\n\t\t\t// 1. On Test Mode, call Transcript.workOnPdf directly\n\t\t\t// 2. On Normal Mode, call QueueWorker.queueWork to queue the work\n\t\t\t// 3. OmnichannelTranscript.workOnPdf will be called by the worker to generate the transcript\n\t\t\t// 4. We be happy :)\n\t\t\tawait requestPdfTranscript(room, this.userId);\n\n\t\t\treturn API.v1.success();\n\t\t},\n\t},\n);\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/api/v1/omnichannel/transcript.ts#L2-L38","documentation":"POST omnichannel/:rid/request-transcript loads the livechat room from the URL param with LivechatRooms.findOneById; a miss throws error-invalid-room. The route requires the request-pdf-transcript permission and an Enterprise license, and only projects _id/open/v/t/pdfTranscriptFileId for the transcript flow.","triggerScenarios":"POST /api/v1/omnichannel/<bogus-rid>/request-transcript — rid typo or truncation, deleted/purged room, a room name instead of id, or a non-omnichannel room id.","commonSituations":"URL-building code that drops or mangles the :rid segment; requesting transcripts for rooms removed by retention; ids copied from another environment.","solutions":["Use the exact room _id in the URL path (GET the room first if unsure) and URL-encode it.","Confirm the room is an omnichannel (type l) room — the endpoint is omnichannel-only.","Gate transcript actions in the UI on a fresh room existence check, not cached state."],"exampleFix":"// before\nawait api.post(`/v1/omnichannel/${rid}/request-transcript`);\n\n// after\nconst info = await api.get('/v1/rooms.info', { params: { roomId: rid } });\nif (info?.room?.t === 'l') {\n  await api.post(`/v1/omnichannel/${encodeURIComponent(rid)}/request-transcript`);\n}","handlingStrategy":"validation","validationCode":"const info = await api.get('/v1/rooms.info', { params: { roomId: rid } });\nif (info?.room?.t === 'l') {\n  await api.post(`/v1/omnichannel/${encodeURIComponent(rid)}/request-transcript`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.post(`/v1/omnichannel/${encodeURIComponent(rid)}/request-transcript`);\n} catch (e) {\n  if (e?.response?.data?.errorType === 'error-invalid-room') {\n    // rid is wrong or the room is gone: re-resolve the room id\n  } else throw e;\n}","preventionTips":["Always URL-encode the :rid path segment.","Use the room _id, never the room name, in the path.","Gate transcript UI on a current room record, not on cached data."],"tags":["omnichannel","transcript","pdf","room","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}